string myFunc(unsigned long pulHKEY_TYPE, int piHKEY_NAME, const string & postr, const string & postrKeyName)
{
DWORD vdwType = pulHKEY_TYPE;
char vch[255];
DWORD vdwDataSize = 255;
memset(vch, 0, 255);
HKEY vHKEY;
long vlRet;
switch(piHKEY_NAME){
case HKEY_L_MACHINE:
vlRet = RegOpenKeyEx(HKEY_LOCAL_MACHINE, string2wstring(postr).c_str(), 0, KEY_READ, &vHKEY);
break;
} // end switch
if(ERROR_SUCCESS == vlRet)
{
vlRet = RegQueryValueEx(vHKEY, string2wstring(postrKeyName).c_str(), NULL, &vdwType, (BYTE *)vch, &vdwDataSize);
if(ERROR_SUCCESS == vlRet)
{
cout << " >> Value: " << vch;
}
else
cout << " >> Query registry failed!";
} // end if-else
string ostr = string(vch);
RegCloseKey(vHKEY);
return ostr;
}
----------------
调用的时候
cout<< myFunc(REG_SZ, myObject.HKEY_L_MACHINE, "SOFTWARE\\Micorsoft\\MediaPlayer\\", "IEInstall");
输出的就是 ""
--
FROM 124.64.247.*