怎样用RegCreateKeyEx()函数在注册表中创建一个自己的键值
编号:QA004030
建立日期: 2001年3月25日 最后修改日期:2001年3月25日
所属类别:
张海洋:
请教一个问题,在VC6.0中,怎样用RegCreateKeyEx()函数或RegCreateKey()函数,在注册表中创建一个自己的键值。谢谢!
回答:
函数说明:
LONG RegCreateKey(
HKEY hKey, // handle to an open key
LPCTSTR lpSubKey, // address of name of subkey to open
PHKEY phkResult // address of buffer for opened handle
);
例子:
//to create subkey "HKEY_LOCAL_MACHINE\SOFTWARE\test"
ret = RegCreateKey(HKEY_LOCAL_MACHINE, "SOFTWARE\test",&hKey)
根据ret判断成功与否。
函数说明:
LONG RegCreateKeyEx(
HKEY hKey, // handle to an open key
LPCTSTR lpSubKey, // address of subkey name
DWORD Reserved, // reserved
LPTSTR lpClass, // address of class string
DWORD dwOptions, // special options flag
REGSAM samDesired, // desired security access
LPSECURITY_ATTRIBUTES lpSecurityAttributes,
// address of key security structure
PHKEY phkResult, // address of buffer for opened handle
LPDWORD lpdwDisposition // address of disposition value buffer
);
用法都差不多。
记住调用RegSetValueEx 或RegSetValue 设置键值,用RegCloseKeyEx 或RegCloseKey 关闭。
相关问题:
QA000012 "如何用VB或VC对Win 95及NT的注册文件进行读写"
此问题由urbane_wolf回答。
| |
|
|
| |
|
|