wwxstar 发表于 2005-3-11 08:17:00

请问注册表的问题

在VBA中如何写入注册表信息呢?


请举个实例说一下吧


谢谢

CADghost 发表于 2005-3-11 11:55:00

SaveSetting和GetSetting

liyuwen 发表于 2005-3-17 16:52:00

不妨参考如下代码:


首先声明相关API调用<BR>Public Const HKEY_CURRENT_USER = &amp;H80000001<BR>Public Const REG_SZ = 1<BR>Public Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long<BR>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.<BR>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.<BR>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<BR>Public Declare Function DiskID32 Lib "XRID.DLL" (ByRef DiskModel As Byte, ByRef DiskID As Byte) As Long<BR>后编写代码如下,即可:


                                       Dim i As Long, j As Long, k As Long, RegCode As String


                                       RegCode = "Registry Test"<BR>                                       i = RegOpenKey(HKEY_CURRENT_USER, "SoftWare", j)<BR>                                       i = RegOpenKey(j, "XX工作室", k)<BR>                                       i = RegOpenKey(k, "XXCAD信息", j)<BR>                                       i = RegSetValueEx(j, "序列号", 0, REG_SZ, RegCode, Len(RegCode))<BR>                                       ...


<BR><BR>
页: [1]
查看完整版本: 请问注册表的问题