by Evan Miller (2 Submissions)
Category: Windows System Services
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Sat 4th May 2002
Date Added: Mon 8th February 2021
Rating:
(1 Votes)
Grab's the ProductID (serial Number) from Windows. This is useful if binding program licence to the Users's O/S. Tip: to make
API Declarations
"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, lpData As Any, _
lpcbData As Long) As Long
Public Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Public Const REG_SZ = 1
Public Const HKEY_LOCAL_MACHINE = &H80000002
Public Const KEY_READ = &H20019
Dim Retval As Long
Dim hKey As Long
Dim TmpSNum As String * 255
' Open Registry Connection
Retval = RegOpenKeyEx(HKEY_LOCAL_MACHINE, _
"Software\Microsoft\Windows\CurrentVersion", 0&, KEY_READ, hKey)
If Retval <> 0 Then
MsgBox "The code could not be opened."
Exit Function
End If
' Query registry
Retval = RegQueryValueEx(hKey, "ProductID", 0, REG_SZ, _
ByVal TmpSNum, Len(TmpSNum))
If Retval <> 0 Then
MsgBox "The code value could not be read or found."
Exit Function
End If
' Get Product-Key
GetWindowsRegKey = Left$(TmpSNum, InStr(1, TmpSNum, vbNullChar) - 1)
'Close Registry
Retval = RegCloseKey(hKey)
End Function
No comments have been posted about Grab's the ProductID (serial Number) from Windows. This is useful if binding program licence to the. Why not be the first to post a comment about Grab's the ProductID (serial Number) from Windows. This is useful if binding program licence to the.