📄 regmanager.cpp
字号:
// RegManager.cpp: implementation of the CRegManager class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "resource.h"
#include "RegManager.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CRegManager::CRegManager()
{
}
CRegManager::~CRegManager()
{
}
int CRegManager::SetDwordRegValue(HKEY RootKey,char *pszkeyPatch,char *pszKeyName,DWORD dwKeyValue)
{
if ( pszkeyPatch == NULL || pszKeyName == NULL )
return -1;
HKEY hKey = NULL;
long lRetCode = RegOpenKeyEx( RootKey,
pszkeyPatch,
0,
KEY_ALL_ACCESS,
&hKey);
DWORD dwResult = 0;
if ( lRetCode != ERROR_SUCCESS )//该键不存在
{
//OUT_DEBUG("%s 不存在" _ pszkeyPatch);
lRetCode = RegCreateKeyEx(RootKey,pszkeyPatch,0L,NULL,REG_OPTION_NON_VOLATILE,
KEY_ALL_ACCESS, NULL,&hKey,&dwResult);
if( lRetCode != ERROR_SUCCESS )
{
//OUT_DEBUG("创建失败");
RegCloseKey(hKey);
return -2;
}
}else{
//OUT_DEBUG("%s 存在" _ pszkeyPatch);
}
if( lRetCode != ERROR_SUCCESS )
{
RegCloseKey(hKey);
return -2;
}
lRetCode = RegSetValueEx(hKey, pszKeyName, 0, REG_DWORD,
(CONST BYTE*) &dwKeyValue, sizeof(DWORD));
if ( lRetCode != ERROR_SUCCESS )
{
RegCloseKey(hKey);
return -3;
}
RegCloseKey(hKey);
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -