Display All System Information using Registry in VB6.0

Today, i will teach you how to display All System Information such as all Hardware Information like OS, CPU, Processor, Memory Information and etc., System Components like networks, CD, DVD, storage information, etc; Software Environment such as system drivers, running tasks, programs, etc; and Internet Settings. We will just access the registry setting for this tutorial. Now, let's start this tutorial! 1. Let's start this tutorial by following the following steps in Microsoft Visual Basic 6.0: Open Microsoft Visual Basic 6.0, click Choose Standard EXE, and click Open. 2. Next, add only one Button named Command1 and labeled it as "Click To Display System Information".You must design your interface like this: design 3. Now add a module in your project named Module1 and put this code below. This is to declare functions and global variables all over the project.
  1. Public Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, phkResult As Long) As Long
  2. Public Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, ByVal lpData As String, lpcbData As Long) As Long
  3. Public Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
  4. Public SysInfoPath As String
  5. Public Const HKEY_LOCAL_MACHINE = &H80000002
  6. Public Const ERROR_SUCCESS = 0&
  7. Public Const READ_CONTROL = &H20000
  8. Public Const KEY_NOTIFY = &H10
  9. Public Const KEY_ENUMERATE_SUB_KEYS = &H8
  10. Public Const KEY_QUERY_VALUE = &H1
  11. Public Const SYNCHRONIZE = &H100000
  12. Public Const STANDARD_RIGHTS_READ = (READ_CONTROL)
  13. Public Const KEY_READ = ((STANDARD_RIGHTS_READ Or KEY_QUERY_VALUE Or KEY_ENUMERATE_SUB_KEYS Or KEY_NOTIFY) And (Not SYNCHRONIZE))
advapi32.dll is used for accessing the registry which is used by applications and Windows to store data. This is why we used many more functions to access advapi32.dll with different alias. We put the RegOpenKeyEx to open registry, RegQueryValueEx to open system information in the registry, and RegCloseKey to close the registry. 4. Then after creating and coding the module, go again to your Form1 and create a function named FindSysInfoPath() As String .
  1. Private Function FindSysInfoPath() As String
  2.  
  3. Dim buf As String
  4. Dim buf_len As Long
  5. Dim info_key As Long
  6. Dim value_type As Long
  7. Dim key_size As Long
  8.  
  9. If RegOpenKeyEx(HKEY_LOCAL_MACHINE, _
  10. "software\microsoft\shared tools\msinfo", _
  11. 0, KEY_READ, info_key) = ERROR_SUCCESS _
  12. Then
  13. buf = Space$(256)
  14. buf_len = Len(buf)
  15. If RegQueryValueEx(info_key, "Path", _
  16. 0, value_type, buf, buf_len) _
  17. = ERROR_SUCCESS _
  18. Then
  19. FindSysInfoPath = Left$(buf, buf_len)
  20. End If
  21. End If
  22. RegCloseKey info_key
  23. End Function
This function code provides access to the system registry. First we used the RegOpenKeyEx as our Public Function in the module to access (HKEY_LOCAL_MACHINE, "software\microsoft\shared tools\msinfo", 0, KEY_READ, info_key) to open the registry setting of the system information. Then the RegQueryValueEx to open the data in the registry setting. And the RegCloseKey to close the registry setting after finding the system information. 5. In your command1 as button to display information, put this code below.
  1. Private Sub Form_Load()
  2. Shell FindSysInfoPath, vbNormalFocus
  3. End Sub
We open and display the system information by using the shell function to run the FindSysInfoPath and will focus on the contents of system information. Output: output Best Regards, Engr. Lyndon R. Bermoy IT Instructor/System Developer/Android Developer/Freelance Programmer If you have some queries, feel free to contact the number or e-mail below. Mobile: 09488225971 Landline: 826-9296 E-mail:[email protected] Visit and like my page on Facebook at: https://www.facebook.com/BermzISware Add and Follow me on Facebook: https://www.facebook.com/donzzsky

Add new comment