CRegKey 封装操作注册表的类
典型的使用方法举例:
//添加和删除程序自启动方法
void RegAddTest()
{
TCHAR m_fileName[MAX_PATH];
GetModuleFileName(NULL,m_fileName,MAX_PATH);
CRegKey hKey;
TCHAR str[] = _T("Software\\Microsoft\\Windows\\CurrentVersion\\Run");
hKey.SetKeyValue(HKEY_LOCAL_MACHINE, str, TEXT("测试"), m_fileName);
}
void RegQueryTest()
{
TCHAR szValue[MAX_PATH];
DWORD dwCount = MAX_PATH;
CRegKey hKey;
TCHAR str[] = _T("Software\\Microsoft\\Windows\\CurrentVersion\\Run");
hKey.Open(HKEY_LOCAL_MACHINE, str);
if(!hKey.QueryValue(TEXT("测试"), szValue, &dwCount))
cout<CRegKey hKey;
TCHAR str[] = _T("Software\\Microsoft\\Windows\\CurrentVersion\\Run");
hKey.Open(HKEY_LOCAL_MACHINE, str);
hKey.DeleteValue(TEXT("测试"));
}
1