Windows registry: how hard can it be... |
Author: |
Message: |
RaceProUK
Elite Member
Posts: 6073 Reputation: 57
39 / /
Joined: Oct 2003
|
O.P. Windows registry: how hard can it be...
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.
This post was edited on 11-19-2003 at 11:33 PM by RaceProUK.
|
|
11-19-2003 11:31 PM |
|
|
chris
Veteran Member
Posts: 1137 Reputation: 2
36 / / –
Joined: May 2003
|
RE: Windows registry: how hard can it be...
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 = MAX_PATH;
unsigned char szValue[MAX_PATH];
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;
}
Try that You can thank DJM for it
This post was edited on 11-20-2003 at 01:54 PM by chris.
|
|
11-20-2003 01:52 PM |
|
|
RaceProUK
Elite Member
Posts: 6073 Reputation: 57
39 / /
Joined: Oct 2003
|
O.P. RE: Windows registry: how hard can it be...
I made the changes, and it still won't work.
I can't remember if I mentioned exactly what the problem is: the code cannot open the registry, let alone read it.
code: {
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);
...
}
It is this section: got to be really.
This post was edited on 11-20-2003 at 02:26 PM by RaceProUK.
|
|
11-20-2003 02:24 PM |
|
|
Hah
Full Member
Im in a good mood - take advantage!
Posts: 224
38 / / –
Joined: May 2003
|
RE: Windows registry: how hard can it be...
It may be stupid but, in my registry editor, the slashes are the other way round! If you havent got it working by now your probably desperate for ideas! so try changing it just to see (doubt it will make a difference though!)
code: "SOFTWARE/Patchou/MsgPlus2"
into
code: "SOFTWARE\Patchou\MsgPlus2"
Ta,
Hah
This post was brought to you by Hah!
(and he takes no responsibility for it )
{Current Web Site}
|
|
11-20-2003 09:18 PM |
|
|
optimism_
Senior Member
Ctrl+Alt+Del - Tragically l337
Posts: 521 Reputation: 8
38 / / –
Joined: Jul 2003
|
RE: Windows registry: how hard can it be...
Change the code to
code: retCode = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\Patchou\MsgPlus2", 0, KEY_QUERY_VALUE, ®Key);
then it should work
This post was edited on 11-21-2003 at 04:50 AM by WDZ.
HTTP 404 - Signature Not Found
|
|
11-21-2003 02:03 AM |
|
|
chris
Veteran Member
Posts: 1137 Reputation: 2
36 / / –
Joined: May 2003
|
RE: Windows registry: how hard can it be...
Ummm there is a bug thing in the code tag so i dunno if that couold have been why it didnt work... so ill just attacch the file.. and hope that it will work.. if not sorry. and good luck at gettin it to work
Attachment: tempcode.txt (1.14 KB)
This file has been downloaded 208 time(s).
|
|
11-21-2003 04:10 AM |
|
|
WDZ
Former Admin
Posts: 7106 Reputation: 107
– / /
Joined: Mar 2002
|
RE: Windows registry: how hard can it be...
Sorry about that bug with backslashes in the [code] tag... it's fixed now.
|
|
11-21-2003 04:52 AM |
|
|
RaceProUK
Elite Member
Posts: 6073 Reputation: 57
39 / /
Joined: Oct 2003
|
O.P. RE: Windows registry: how hard can it be...
(bangs head repeatedly on table, recovers from the concussion, then changes the slashes so they are correct)
at my error. ( Cue repeated swearing at himself - Ed)
Now all I need to do is get the default string code to work correctly, then I can start work on releases.
This post was edited on 11-21-2003 at 03:24 PM by RaceProUK.
|
|
11-21-2003 03:22 PM |
|
|
|
|