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 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 ' Note that if you declare the lpData parameter as String, you must pass it By Value. Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As LongPrivate Const HKEY_LOCAL_MACHINE = &H80000002 Private Const REG_SZ = 1Private Sub Command1_Click() Dim hKey As Long RegCreateKey HKEY_LOCAL_MACHINE, "HARDWARE", hKey If hKey > 0 Then RegSetValueEx hKey, "", 0, REG_SZ, ByVal "中国人民是不可战胜的", 25 RegCloseKey hKey End If End Sub
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 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 ' Note that if you declare the lpData parameter as String, you must pass it By Value.
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As LongPrivate Const HKEY_LOCAL_MACHINE = &H80000002
Private Const REG_SZ = 1Private Sub Command1_Click()
Dim hKey As Long
RegCreateKey HKEY_LOCAL_MACHINE, "HARDWARE", hKey
If hKey > 0 Then
RegSetValueEx hKey, "", 0, REG_SZ, ByVal "中国人民是不可战胜的", 25
RegCloseKey hKey
End If
End Sub
另外取長度時,用lenb來取。