USUÁRIO:      SENHA:        SALVAR LOGIN ?    Adicione o VBWEB na sua lista de favoritos   Fale conosco 

 

  Dicas

  Visual Basic    (Windows)

Título da Dica:  Descobrindo o número serial do Windows instalado
Postada em 27/9/2003 por ^HEAVY-METAL^            
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, 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


Public Function GetWindowsRegKey() As String
  Dim Retval As Long
  Dim hKey As Long
  Dim TmpSNum As String * 255

  Rem  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

  Rem  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

  Rem  Get Product-Key
  GetWindowsRegKey = Left$(TmpSNum, InStr(1, TmpSNum, vbNullChar) - 1)

  Rem Close Registry
  Retval = RegCloseKey(hKey)

End Function
 


CyberWEB Network Ltda.    © Copyright 2000-2024   -   Todos os direitos reservados.
Powered by HostingZone - A melhor hospedagem para seu site
Topo da página