Foros del Web » Programación para mayores de 30 ;) » Programación General » Visual Basic clásico »

Ayuda con nombre de pc

Estas en el tema de Ayuda con nombre de pc en el foro de Visual Basic clásico en Foros del Web. Saludos bueno pues me gustaria como poder sacar el nombre de la pc por medio de vb...
  #1 (permalink)  
Antiguo 02/01/2006, 15:30
 
Fecha de Ingreso: diciembre-2003
Mensajes: 595
Antigüedad: 20 años, 4 meses
Puntos: 1
Ayuda con nombre de pc

Saludos bueno pues me gustaria como poder sacar el nombre de la pc por medio de vb
  #2 (permalink)  
Antiguo 03/01/2006, 02:03
 
Fecha de Ingreso: abril-2004
Mensajes: 192
Antigüedad: 20 años
Puntos: 0
Mediante el api

Sacado del Apiguide:

'example by Donavon Kuhn ([email protected])
Private Const MAX_COMPUTERNAME_LENGTH As Long = 31
Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Private Sub Form_Load()
Dim dwLen As Long
Dim strString As String
'Create a buffer
dwLen = MAX_COMPUTERNAME_LENGTH + 1
strString = String(dwLen, "X")
'Get the computer name
GetComputerName strString, dwLen
'get only the actual data
strString = Left(strString, dwLen)
'Show the computer name
MsgBox strString
End Sub



Mi web sobre Visual:
http://ar.geocities.com/recursosvb
  #3 (permalink)  
Antiguo 03/01/2006, 07:53
 
Fecha de Ingreso: diciembre-2003
Mensajes: 595
Antigüedad: 20 años, 4 meses
Puntos: 1
Cita:
Iniciado por luciano
Sacado del Apiguide:

'example by Donavon Kuhn ([email protected])
Private Const MAX_COMPUTERNAME_LENGTH As Long = 31
Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Private Sub Form_Load()
Dim dwLen As Long
Dim strString As String
'Create a buffer
dwLen = MAX_COMPUTERNAME_LENGTH + 1
strString = String(dwLen, "X")
'Get the computer name
GetComputerName strString, dwLen
'get only the actual data
strString = Left(strString, dwLen)
'Show the computer name
MsgBox strString
End Sub



Mi web sobre Visual:
http://ar.geocities.com/recursosvb
muchas gracias luciano
  #4 (permalink)  
Antiguo 05/01/2006, 20:45
 
Fecha de Ingreso: noviembre-2005
Mensajes: 43
Antigüedad: 18 años, 5 meses
Puntos: 0
Obteniendo nombre PC y otros...

Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Private Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Private Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long

Private Sub Command4_Click()
'Obtener directorio de Windows
Dim Ret As Long
Dim sBuffer As String
Dim nSize As Long

sBuffer = Space(255)
nSize = Len(sBuffer)
Ret = GetWindowsDirectory(sBuffer, nSize)
MsgBox "Directorio de Windows: " & Left$(sBuffer, Len(sBuffer))
End Sub

Private Sub Command1_Click()
'Obtener nombre del PC
Dim sBuffer As String
Dim nSize As Long
Dim Ret As Long

sBuffer = Space(255)
nSize = Len(sBuffer)
Ret = GetComputerName(sBuffer, nSize)
MsgBox "Nombre de PC: " & Left$(sBuffer, Len(sBuffer))
End Sub

Private Sub Command2_Click()
'Obtener nombre de usuario
Dim sBuffer As String
Dim nSize As Long
Dim Ret As Long

sBuffer = Space(255)
nSize = Len(sBuffer)
Ret = GetUserName(sBuffer, nSize)
MsgBox "Nombre de usuario: " & Left$(sBuffer, Len(sBuffer))
End Sub

Private Sub Command5_Click()
'Obtener directorio de la carpeta del sistema ( System32 )
Dim sBuffer As String
Dim nSize As Long
Dim Ret As Long

sBuffer = Space(255)
nSize = Len(sBuffer)
Ret = GetSystemDirectory(sBuffer, nSize)
MsgBox "El directorio del sistema es: " & Left$(sBuffer, Len(sBuffer))
End Sub

  #5 (permalink)  
Antiguo 06/01/2006, 08:15
 
Fecha de Ingreso: diciembre-2003
Mensajes: 595
Antigüedad: 20 años, 4 meses
Puntos: 1
Cita:
Iniciado por vvictoristudio
Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Private Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Private Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long

Private Sub Command4_Click()
'Obtener directorio de Windows
Dim Ret As Long
Dim sBuffer As String
Dim nSize As Long

sBuffer = Space(255)
nSize = Len(sBuffer)
Ret = GetWindowsDirectory(sBuffer, nSize)
MsgBox "Directorio de Windows: " & Left$(sBuffer, Len(sBuffer))
End Sub

Private Sub Command1_Click()
'Obtener nombre del PC
Dim sBuffer As String
Dim nSize As Long
Dim Ret As Long

sBuffer = Space(255)
nSize = Len(sBuffer)
Ret = GetComputerName(sBuffer, nSize)
MsgBox "Nombre de PC: " & Left$(sBuffer, Len(sBuffer))
End Sub

Private Sub Command2_Click()
'Obtener nombre de usuario
Dim sBuffer As String
Dim nSize As Long
Dim Ret As Long

sBuffer = Space(255)
nSize = Len(sBuffer)
Ret = GetUserName(sBuffer, nSize)
MsgBox "Nombre de usuario: " & Left$(sBuffer, Len(sBuffer))
End Sub

Private Sub Command5_Click()
'Obtener directorio de la carpeta del sistema ( System32 )
Dim sBuffer As String
Dim nSize As Long
Dim Ret As Long

sBuffer = Space(255)
nSize = Len(sBuffer)
Ret = GetSystemDirectory(sBuffer, nSize)
MsgBox "El directorio del sistema es: " & Left$(sBuffer, Len(sBuffer))
End Sub

gracias
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 15:19.