引用 3 楼 xumercury 的回复:
C/C++ code///////////////////////////////////////////////////////////////////////////////////////////////////Title:RegisterMangement//Input:TCHAR KeyName, DWORD KeyValue,T_OPERA_MODE operation//Output:BOOL// if register set ok,return TRUE,else return FALSE//Descrpition:This founction is modify the register of the xxxx. Include xxx,bass and treble.//Author:Mercury//Date:20091215/////////////////////////////////////////////////////////////////////////////////////////////////BOOL RegisterMangement(const TCHAR* KeyName, DWORD KeyValue,T_OPERA_MODE operation)
{
HKEY hKey= NULL;
DWORD dwResult=0;
DWORD dwType= REG_DWORD;
DWORD dwSize=sizeof(DWORD);if (ERROR_SUCCESS== RegOpenKeyEx(HKEY_LOCAL_MACHINE, RegPath,0, KEY_WRITE|KEY_READ,&hKey))
{if(WRITE== operation)
{
dwResult= RegSetValueEx(hKey,KeyName,0,REG_DWORD,(LPBYTE)&KeyValue,sizeof(DWORD));if(!dwResult)
{
RETAILMSG(1,(TEXT("RegisterMangement WRITE SET VALUE !The RETURN value is 0x%x\r\n"),dwResult));
RETAILMSG(1,(TEXT("RegisterMangement WRITE SET VALUE OK!\r\n")));
RegCloseKey(hKey);return TRUE;
}else
{
RETAILMSG(1,(TEXT("RegisterMangement WRITE SET VALUE !The RETURN value is 0x%x\r\n"),dwResult));
RETAILMSG(1,(TEXT("RegisterMangement WRITE SET VALUE FALSE!\r\n")));
RegCloseKey(hKey);return FALSE;
}
}elseif(READ== operation)
{
dwResult= RegQueryValueEx(hKey,KeyName,0,&dwType,(LPBYTE)&KeyValue,&dwSize);if(!dwResult)
{
RETAILMSG(1,(TEXT("RegisterMangement READ SET VALUE !The RETURN value is 0x%x\r\n"),dwResult));
RETAILMSG(1,(TEXT("RegisterMangement READ SET VALUE OK!The value is 0x%x\r\n"),KeyValue));
RegCloseKey(hKey);return TRUE;
}else
{
RETAILMSG(1,(TEXT("RegisterMangement READ SET VALUE FALSE!The RETURN value is 0x%x\r\n"),dwResult));
RETAILMSG(1,(TEXT("RegisterMangement READ SET VALUE FALSE!\r\n")));
RegCloseKey(hKey);return FALSE;
}
}else
{return FALSE;
}
}elsereturn FALSE;
}
我这是调试通过的。。你比比看。。。