忽略警告:
#pragma warning(disable: 4172)
读取注册表
LPCSTR Tools_ReadRegedit(char * sPath, char * sNodeName)
{
HKEY hKey;
DWORD type;
DWORD dataLen = 30;
TCHAR dataBuffer[30] = {0};
if(ERROR_SUCCESS != RegOpenKeyEx(HKEY_LOCAL_MACHINE,sPath, 0, KEY_READ, &hKey) )
{
return "0";
}
if( ERROR_SUCCESS !=RegQueryValueEx(hKey, sNodeName, NULL, &type, (LPBYTE)dataBuffer, &dataLen))
{
RegCloseKey(hKey);
return "0";
}
if (REG_SZ != type)
{
RegCloseKey(hKey);
return "0";
}
RegCloseKey(hKey);
dataBuffer[dataLen] = '\0';
return (char*)dataBuffer;
}