明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1273|回复: 2

请问注册表的问题

[复制链接]
发表于 2005-3-11 08:17:00 | 显示全部楼层 |阅读模式
在VBA中如何写入注册表信息呢?


请举个实例说一下吧


谢谢
发表于 2005-3-11 11:55:00 | 显示全部楼层
SaveSetting和GetSetting
发表于 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))
...

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-27 18:42 , Processed in 0.178061 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表