Grab's the ProductID (serial Number) from Windows. This is useful if binding program licence to the
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
Rate Grab's the ProductID (serial Number) from Windows. This is useful if binding program licence to the
(2(2 Vote))
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
Grab's the ProductID (serial Number) from Windows. This is useful if binding program licence to the Comments
No comments yet — be the first to post one!
Post a Comment