What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Plug-Ins » Windows registry: how hard can it be...

Windows registry: how hard can it be...
Author: Message:
RaceProUK
Elite Member
*****

Avatar

Posts: 6073
Reputation: 57
39 / Male / Flag
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, &regKey);
    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.
[Image: spartaafk.png]
11-19-2003 11:31 PM
Profile PM Web Find Quote Report
chris
Veteran Member
*****


Posts: 1137
Reputation: 2
36 / Male / –
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:p

This post was edited on 11-20-2003 at 01:54 PM by chris.
11-20-2003 01:52 PM
Profile PM Find Quote Report
RaceProUK
Elite Member
*****

Avatar

Posts: 6073
Reputation: 57
39 / Male / Flag
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, &regKey);
    ...
}

It is this section: got to be really.

This post was edited on 11-20-2003 at 02:26 PM by RaceProUK.
[Image: spartaafk.png]
11-20-2003 02:24 PM
Profile PM Web Find Quote Report
Hah
Full Member
***

Avatar
Im in a good mood - take advantage!

Posts: 224
37 / Male / –
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 :p)

[Image: signatures.jpg]

{Current Web Site}
11-20-2003 09:18 PM
Profile E-Mail PM Web Find Quote Report
optimism_
Senior Member
****

Avatar
Ctrl+Alt+Del - Tragically l337

Posts: 521
Reputation: 8
38 / Male / –
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, &regKey);


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
Profile E-Mail PM Web Find Quote Report
chris
Veteran Member
*****


Posts: 1137
Reputation: 2
36 / Male / –
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

.txt File Attachment: tempcode.txt (1.14 KB)
This file has been downloaded 206 time(s).
11-21-2003 04:10 AM
Profile PM Find Quote Report
WDZ
Former Admin
*****

Avatar

Posts: 7106
Reputation: 107
– / Male / Flag
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
Profile PM Web Find Quote Report
RaceProUK
Elite Member
*****

Avatar

Posts: 6073
Reputation: 57
39 / Male / Flag
Joined: Oct 2003
O.P. RE: Windows registry: how hard can it be...
:S (bangs head repeatedly on table, recovers from the concussion, then changes the slashes so they are correct)

:$ at my [Image: newbie.gif] 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. :type:

This post was edited on 11-21-2003 at 03:24 PM by RaceProUK.
[Image: spartaafk.png]
11-21-2003 03:22 PM
Profile PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On