強力鎯頭 VB BLOG

文章分類

每月文章

文章標籤

全部標籤

讀取登錄檔內機碼

如何用VB讀取登錄檔的機碼

'
兩種方式 

' 1.
使用 API 

Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long 
Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" _ 
            (ByVal hKey As Long, _ 
            ByVal lpSubKey As String, _ 
            phkResult As Long) As Long 

Private Declare Function RegDeleteValue Lib "advapi32.dll" Alias "RegDeleteValueA" 
            (ByVal hKey As Long, _ 
            ByVal lpValueName As String) As Long 

Private Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" _ 
            (ByVal hKey As Long, _ 
            ByVal lpSubKey As String, _ 
            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, _ 
            lpType As Long, _ 
            lpData As Any, _ 
            lpcbData As Long) As Long 

Private Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" _
            (ByVal hKey As Long, _ 
            ByVal lpValueName As String, _ 
            ByVal Reserved As Long, _ 
            ByVal dwType As Long, _ 
            lpData As Any, _ 
            ByVal cbData As Long) As Long 

(
較麻煩

 

================================================================



' 2.
使用 Wsh ( Windows Scripting Host ) 

    Dim WshShell As Object 
    Set WshShell = CreateObject("WScript.Shell") '
建立 Wsh Shell 物件 
    MsgBox WshShell.RegRead("登錄檔機碼") ' 透過該物件 RegRead 方法 讀取登錄檔某機碼

posted on 2008/3/24 21:27 | 我要推薦 | 閱讀數 : 1139 | 文章分類 [ VB / VBA ] 訂閱

Feedback

# re: 讀取登錄檔內機碼 2009/5/5 下午 06:25 林彬彬 回覆

想學習

標題
姓名
電子郵件 (將不會被顯示)
個人網頁
內容
登入後使用進階評論
Please add 1 and 7 and type the answer here: