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:
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.
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
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
Public Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Public SysInfoPath As String
Public Const HKEY_LOCAL_MACHINE = &H80000002
Public Const ERROR_SUCCESS = 0&
Public Const READ_CONTROL = &H20000
Public Const KEY_NOTIFY = &H10
Public Const KEY_ENUMERATE_SUB_KEYS = &H8
Public Const KEY_QUERY_VALUE = &H1
Public Const SYNCHRONIZE = &H100000
Public Const STANDARD_RIGHTS_READ = (READ_CONTROL)
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 .
Private Function FindSysInfoPath() As String
Dim buf As String
Dim buf_len As Long
Dim info_key As Long
Dim value_type As Long
Dim key_size As Long
If RegOpenKeyEx(HKEY_LOCAL_MACHINE, _
"software\microsoft\shared tools\msinfo", _
0, KEY_READ, info_key) = ERROR_SUCCESS _
Then
buf = Space$(256)
buf_len = Len(buf)
If RegQueryValueEx(info_key, "Path", _
0, value_type, buf, buf_len) _
= ERROR_SUCCESS _
Then
FindSysInfoPath = Left$(buf, buf_len)
End If
End If
RegCloseKey info_key
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.
Private Sub Form_Load()
Shell FindSysInfoPath, vbNormalFocus
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:
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