View Full Version : Problem in reading the Media File Installation path


kishor.mittur@gmail.com
09-15-2005, 07:38 AM
Why I am not getting the Registry value with the following code?

Thanks for ur time and advise


long lRet;
HKEY hKeySettings;

DWORD dwSize;
DWORD nType = REG_SZ;
dwSize=MAX_PATH ;

char* szValName="Installation Directory";
char* dwSettingsData=NULL;
try
{
lRet = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
"SOFTWARE\\Microsoft\\MediaPlayer",0, KEY_ALL_ACCESS, &hKeySettings);
if (lRet==ERROR_SUCCESS)
{
MessageBox("Pass1","",MB_OK);
}
}
catch(...)
{
MessageBox("fail1","",MB_OK);
}
try
{
lRet = RegQueryValueEx(hKeySettings, szValName, NULL, NULL,
(LPBYTE)dwSettingsData, &dwSize);

if (lRet==ERROR_SUCCESS)
{
MessageBox("Pass2","",MB_OK);
}
}
catch(...)
{
MessageBox("fail2","",MB_OK);
}


MessageBox((LPCTSTR)dwSettingsData,"",MB_OK);
RegCloseKey(hKeySettings);