Shoutbox

Windows registry: how hard can it be... - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Forum: Plug-Ins (/forumdisplay.php?fid=28)
+------ Thread: Windows registry: how hard can it be... (/showthread.php?tid=18363)

Windows registry: how hard can it be... by RaceProUK on 11-19-2003 at 11:31 PM

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.
RE: Windows registry: how hard can it be... by chris on 11-20-2003 at 01:52 PM

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
RE: Windows registry: how hard can it be... by RaceProUK on 11-20-2003 at 02:24 PM

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.
RE: Windows registry: how hard can it be... by Hah on 11-20-2003 at 09:18 PM

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

RE: Windows registry: how hard can it be... by optimism_ on 11-21-2003 at 02:03 AM

Change the code to

code:
retCode = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\Patchou\MsgPlus2", 0, KEY_QUERY_VALUE, &regKey);


then it should work

RE: Windows registry: how hard can it be... by chris on 11-21-2003 at 04:10 AM

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


RE: Windows registry: how hard can it be... by WDZ on 11-21-2003 at 04:52 AM

Sorry about that bug with backslashes in the

code:
tag... it's fixed now.

RE: Windows registry: how hard can it be... by RaceProUK on 11-21-2003 at 03:22 PM

: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: