您的位置:首页 > 其它

Windows SDK Registry: How can I write data to the registry?

2011-03-30 23:32 441 查看
Q: How can I write data to the registry?
A:
Code:

HKEY hKey;

if(::RegOpenKeyEx(HKEY_LOCAL_MACHINE,
"System//CurrentControlSet//Control//Windows",
0,
KEY_SET_VALUE,
&hKey) == ERROR_SUCCESS)
{
DWORD dwValue = 245;

// Set value
if(::RegSetValueEx(hKey,
"NameOfValue",
0,
REG_DWORD,
reinterpret_cast<BYTE *>(&dwValue),
sizeof(dwValue)) != ERROR_SUCCESS)
{
// Close key
::RegCloseKey(hKey);

// Error handling;
}

// Close key
::RegCloseKey(hKey);
}
else
// Error handling;


原文出处:http://www.codeguru.com/forum/showthread.php?s=&threadid=247022
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  windows
相关文章推荐