- 积分
- 2314
- 明经币
- 个
- 注册时间
- 2003-8-15
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
发表于 2005-3-17 16:52:00
|
显示全部楼层
不妨参考如下代码:
首先声明相关API调用 Public Const HKEY_CURRENT_USER = &H80000001 Public Const REG_SZ = 1 Public Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, 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, ByVal lpType As Long, ByVal lpData As String, lpcbData As Long) As Long ' Note that if you declare the lpData parameter as String, you must pass it By Value. Public Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, ByVal 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. Public Declare Function GetVolumeInformation Lib "kernel32" Alias "GetVolumeInformationA" (ByVal lpRootPathName As String, ByVal lpVolumeNameBuffer As String, ByVal nVolumeNameSize As Long, lpVolumeSerialNumber As Long, lpMaximumComponentLength As Long, lpFileSystemFlags As Long, ByVal lpFileSystemNameBuffer As String, ByVal nFileSystemNameSize As Long) As Long Public Declare Function DiskID32 Lib "XRID.DLL" (ByRef DiskModel As Byte, ByRef DiskID As Byte) As Long 后编写代码如下,即可:
Dim i As Long, j As Long, k As Long, RegCode As String
RegCode = "Registry Test" i = RegOpenKey(HKEY_CURRENT_USER, "SoftWare", j) i = RegOpenKey(j, "XX工作室", k) i = RegOpenKey(k, "XXCAD信息", j) i = RegSetValueEx(j, "序列号", 0, REG_SZ, RegCode, Len(RegCode)) ...
|
|