Your technology certification is waiting. Enroll in Cloud Class ®
Option Compare Database
Private Const HKEY_CURRENT_USER = &H80000001
Private Const HKEY_LOCAL_MACHINE = &H80000002
Private Const KEY_READ = &H20019
Private Const REG_SZ = 1
Private 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
Private Declare Function RegQueryValueEx Lib "advapi32.dll" _
Alias "RegQueryValueExA" ( _
ByVal hKey As Long, _
ByVal lpValueName As String, _
ByVal lpReserved As Long, _
ByRef lpType As Long, _
ByRef lpData As Any, _
ByRef lpcbData As Long) As Long
Private Declare Function RegCloseKey Lib "advapi32.dll" ( _
ByVal hKey As Long) As Long
Private Sub ReadRegistry( _
hKey As Long, _
subkey As String, _
ValueVar As String, _
DataVar As String)
Dim datatype As Long ' receives data type of read value
Dim DataLen As Long ' receives length of returned data
Dim retval As Long ' return value
' hKey: receives a handle to the newly created or opened registry key
' subkey: name of the subkey to open
' DataVar: receives data read from the registry
' datatype: receives data type of read value
' DataLen: receives length of returned data
' retval: return value
' Open the registry key.
retval = RegOpenKeyEx(hKey, subkey, 0, KEY_READ, hKey)
If retval = 0 Then
' Create buffer to receive the incoming data.
DataLen = 255
DataVar = Space(DataLen)
' Read the value from the registry key.
retval = RegQueryValueEx(hKey, ValueVar, 0, datatype, ByVal DataVar, DataLen)
' Only attempt to display the data if it is in fact a string.
If datatype = REG_SZ Then
' Remove zero termination and empty space from the buffer.
DataVar = Left(DataVar, DataLen - 1)
' Close the registry key.
retval = RegCloseKey(hKey)
Open in new window
Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.
One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
Please enter a first name
Please enter a last name
Must be at least 4 characters long.
Join and Comment
From novice to tech pro — start learning today.
Premium members can enroll in this course at no extra cost.