1.如何向注册表中写值
//写入注册表为DWORD类型
bool SetRegValue(LPCTSTR lpSubKey, LPCTSTR lpValueName, DWORD dwValueKey)
{
bool bRet = false;
HKEY hKey;
DWORD dwDispoistion = REG_OPENED_EXISTING_KEY;
if (ERROR_SUCCESS == ::RegCreateKeyEx(HKEY_LOCAL_MACHINE, lpSubKey, 0, NULL, REG_OPTION_NON_VOLATILE,
KEY_WRITE, NULL, &hKey, &dwDispoistion))
{
if (ERROR_SUCCESS == ::RegSetValueEx(hKey, lpValueName, 0, REG_DWORD, (BYTE*)&dwValueKey, sizeof(DWORD)))
{
bRet = true;
}
}
::RegCloseKey(hKey);
return bRet;
}
// 写入注册表为LPCTSTR 类型
bool SetRegValue(LPCTSTR lpSubKey, LPCTSTR lpValueName, LPCTSTR lpValueKey)
{
bool bRet = false;
HKEY hKey;
DWORD dwDisposition = REG_OPENED_EXISTING_KEY;
if (ERROR_SUCCESS == ::RegCreateKeyEx(HKEY_LOCAL_MACHINE, lpSubKey, 0, NULL, REG_OPTION_NON_VOLATILE,
KEY_WRITE, NULL, &hKey, &dwDisposition))
{

最低0.47元/天 解锁文章
1万+

被折叠的 条评论
为什么被折叠?



