I know this sort of carries on from my last topic, but this problem is unrelated. Promise.
OK, here we go. I haven't yet figured out how to embed the sound data in the .dll, so I am trying to use the registry to find the Msg+ plugins directory, and reference my sound files that way. However, I cannot get the code to open the registry.
Here is the offending code:
code:
MPPLUGIN_RETURN_BOOL Initialize(/*[in]*/ DWORD nVersion,
/*[in]*/ const char* sUserEmail,
/*[in]*/ IDispatch* iMessengerObj)
{
bool retValue = TRUE;
long retCode = 0;
HKEY regKey;
unsigned long *szType = 0, *szSize = 0;
unsigned char *szValue = 0;
retCode = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE/Patchou/MsgPlus2",
0, KEY_QUERY_VALUE, ®Key);
if (retCode != ERROR_SUCCESS)
{
MessageBox(NULL, "Error opening registry", "Error", MB_OK);
retValue = FALSE;
}
else
{
retCode = RegQueryValueEx(regKey, "PluginDir", NULL,
szType, szValue, szSize);
if (retCode != ERROR_SUCCESS){ retValue = FALSE;
MessageBox(NULL, "Error reading registry", "Error", MB_OK);
}
else strcpy(sPluginPath,
reinterpret_cast<const char*>(szValue));
}
retCode = RegCloseKey(regKey);
if (retCode != ERROR_SUCCESS){ retValue = FALSE;
MessageBox(NULL, "Error closing registry", "Error", MB_OK);
}
return retValue;
}
It compiles, it runs, but it doesn't work.
The message boxes are to help me (try to) debug.
Any suggestions? All welcome.