• Miércoles 15 de Mayo de 2024, 00:07

Autor Tema:  Información Del Sistema  (Leído 1626 veces)

antonio Sw

  • Nuevo Miembro
  • *
  • Mensajes: 16
    • Ver Perfil
Información Del Sistema
« en: Miércoles 22 de Septiembre de 2004, 08:37 »
0
Hola a todos:

   Necesito sacar información del sistema, como que windows tiene el usuario (xp, 2000, me, 98), número de serie del disco duro, nombre de la tarjeta grafica, memorio. ¿Alguien me podría pasar algo de código?  No encuentro nada por internet.

  Muchas Gracias...

  Antonio.

RadicalEd

  • Moderador
  • ******
  • Mensajes: 2430
  • Nacionalidad: co
    • Ver Perfil
Re: Información Del Sistema
« Respuesta #1 en: Miércoles 22 de Septiembre de 2004, 19:07 »
0
MIRA TODO ESTE CODIGO LO SACA EL WIZARD DE VB Y PUEDES VER TODA LA INFORMACION DEL SISTEMA
Código: Text
  1.  
  2. ' Reg Key Security Options...
  3. Const KEY_ALL_ACCESS = &H2003F
  4.                                          
  5.  
  6. ' Reg Key ROOT Types...
  7. Const HKEY_LOCAL_MACHINE = &H80000002
  8. Const ERROR_SUCCESS = 0
  9. Const REG_SZ = 1                         ' Unicode nul terminated string
  10. Const REG_DWORD = 4                      ' 32-bit number
  11.  
  12.  
  13. Const gREGKEYSYSINFOLOC = "SOFTWARE\Microsoft\Shared Tools Location"
  14. Const gREGVALSYSINFOLOC = "MSINFO"
  15. Const gREGKEYSYSINFO = "SOFTWARE\Microsoft\Shared Tools\MSINFO"
  16. Const gREGVALSYSINFO = "PATH"
  17.  
  18.  
  19. Private Declare Function RegOpenKeyEx Lib "advapi32" Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, ByRef phkResult As Long) As Long
  20. Private Declare Function RegQueryValueEx Lib "advapi32" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, ByRef lpType As Long, ByVal lpData As String, ByRef lpcbData As Long) As Long
  21. Private Declare Function RegCloseKey Lib "advapi32" (ByVal hKey As Long) As Long
  22.  
  23. Private Sub Form_Load()
  24.     LoadResStrings Me
  25.     lblVersion.Caption = "Version " & App.Major & "." & App.Minor & "." & App.Revision
  26.     lblTitle.Caption = App.Title
  27. End Sub
  28.  
  29.  
  30.  
  31.  
  32.  
  33. Private Sub cmdSysInfo_Click()
  34.         Call StartSysInfo
  35. End Sub
  36.  
  37.  
  38. Private Sub cmdOK_Click()
  39.         Unload Me
  40. End Sub
  41.  
  42.  
  43. Public Sub StartSysInfo()
  44.     On Error GoTo SysInfoErr
  45.  
  46.  
  47.         Dim rc As Long
  48.         Dim SysInfoPath As String
  49.        
  50.  
  51.         ' Try To Get System Info Program Path\Name From Registry...
  52.         If GetKeyValue(HKEY_LOCAL_MACHINE, gREGKEYSYSINFO, gREGVALSYSINFO, SysInfoPath) Then
  53.         ' Try To Get System Info Program Path Only From Registry...
  54.         ElseIf GetKeyValue(HKEY_LOCAL_MACHINE, gREGKEYSYSINFOLOC, gREGVALSYSINFOLOC, SysInfoPath) Then
  55.                 ' Validate Existance Of Known 32 Bit File Version
  56.                 If (Dir(SysInfoPath & "\MSINFO32.EXE") <> "") Then
  57.                         SysInfoPath = SysInfoPath & "\MSINFO32.EXE"
  58.                        
  59.  
  60.                 ' Error - File Can Not Be Found...
  61.                 Else
  62.                         GoTo SysInfoErr
  63.                 End If
  64.         ' Error - Registry Entry Can Not Be Found...
  65.         Else
  66.                 GoTo SysInfoErr
  67.         End If
  68.        
  69.  
  70.         Call Shell(SysInfoPath, vbNormalFocus)
  71.        
  72.  
  73.         Exit Sub
  74. SysInfoErr:
  75.         MsgBox "System Information Is Unavailable At This Time", vbOKOnly
  76. End Sub
  77.  
  78.  
  79. Public Function GetKeyValue(KeyRoot As Long, KeyName As String, SubKeyRef As String, ByRef KeyVal As String) As Boolean
  80.         Dim i As Long                                           ' Loop Counter
  81.         Dim rc As Long                                          ' Return Code
  82.         Dim hKey As Long                                        ' Handle To An Open Registry Key
  83.         Dim hDepth As Long                                      '
  84.         Dim KeyValType As Long                                  ' Data Type Of A Registry Key
  85.         Dim tmpVal As String                                    ' Tempory Storage For A Registry Key Value
  86.         Dim KeyValSize As Long                                  ' Size Of Registry Key Variable
  87.         '------------------------------------------------------------
  88.         ' Open RegKey Under KeyRoot {HKEY_LOCAL_MACHINE...}
  89.         '------------------------------------------------------------
  90.         rc = RegOpenKeyEx(KeyRoot, KeyName, 0, KEY_ALL_ACCESS, hKey) ' Open Registry Key
  91.        
  92.  
  93.         If (rc <> ERROR_SUCCESS) Then GoTo GetKeyError          ' Handle Error...
  94.        
  95.  
  96.         tmpVal = String$(1024, 0)                             ' Allocate Variable Space
  97.         KeyValSize = 1024                                       ' Mark Variable Size
  98.        
  99.  
  100.         '------------------------------------------------------------
  101.         ' Retrieve Registry Key Value...
  102.         '------------------------------------------------------------
  103.         rc = RegQueryValueEx(hKey, SubKeyRef, 0, KeyValType, tmpVal, KeyValSize)    ' Get/Create Key Value
  104.                                                
  105.  
  106.         If (rc <> ERROR_SUCCESS) Then GoTo GetKeyError          ' Handle Errors
  107.        
  108.  
  109.         If (Asc(Mid(tmpVal, KeyValSize, 1)) = 0) Then           ' Win95 Adds Null Terminated String...
  110.                 tmpVal = Left(tmpVal, KeyValSize - 1)               ' Null Found, Extract From String
  111.         Else                                                    ' WinNT Does NOT Null Terminate String...
  112.                 tmpVal = Left(tmpVal, KeyValSize)                   ' Null Not Found, Extract String Only
  113.         End If
  114.         '------------------------------------------------------------
  115.         ' Determine Key Value Type For Conversion...
  116.         '------------------------------------------------------------
  117.         Select Case KeyValType                                  ' Search Data Types...
  118.         Case REG_SZ                                             ' String Registry Key Data Type
  119.                 KeyVal = tmpVal                                     ' Copy String Value
  120.         Case REG_DWORD                                          ' Double Word Registry Key Data Type
  121.                 For i = Len(tmpVal) To 1 Step -1                    ' Convert Each Bit
  122.                         KeyVal = KeyVal + Hex(Asc(Mid(tmpVal, i, 1)))   ' Build Value Char. By Char.
  123.                 Next
  124.                 KeyVal = Format$("&h" + KeyVal)                     ' Convert Double Word To String
  125.         End Select
  126.        
  127.  
  128.         GetKeyValue = True                                      ' Return Success
  129.         rc = RegCloseKey(hKey)                                  ' Close Registry Key
  130.         Exit Function                                           ' Exit
  131.        
  132.  
  133. GetKeyError:    ' Cleanup After An Error Has Occured...
  134.         KeyVal = ""                                             ' Set Return Val To Empty String
  135.         GetKeyValue = False                                     ' Return Failure
  136.         rc = RegCloseKey(hKey)                                  ' Close Registry Key
  137. End Function
  138.  
[/color]
El pasado son solo recuerdos, el futuro son solo sueños

Daniel_PC

  • Miembro activo
  • **
  • Mensajes: 59
    • Ver Perfil
Re: Información Del Sistema
« Respuesta #2 en: Martes 12 de Octubre de 2004, 05:46 »
0
hola si quieres algo mas simple para obtener informacion de tu pc Buscar por WMI

aqui te envio un ejemplo de lo que puedes obtener

Daniel PC
El mensaje contiene 1 archivo adjunto. Debes ingresar o registrarte para poder verlo y descargarlo.