Hi all
I wanted in my wxMSW 2.5.2 based app to replace the ugly (but perfect working) win32 code with the elegant wxWidgets wrappings, but I can't make it work.
#ifdef __WIN32__
#include <wx/msw/registry.h>
#endif
wxRegKey RegkeyCurrentUser("HKCU\\Software\\Skype\\Phone\\SkypePath" );
wxString path;
if (RegkeyCurrentUser.Exists())
{
RegkeyCurrentUser.Open();
path = RegkeyCurrentUser;
wxLogMessage(path);
}
but this snippet does not work.
Anybody a clue how to query keys in the windows registries ?
regards
Roberto
wxRegKey Problem on wxMSW
IIRC... (this is not tested, from just memory)
Should be more like:
You can also can test if "keyname" exists before querying the value by:
Hope that sheds some light.
CG
Code: Select all
if (RegkeyCurrentUser.Exists())
{
RegkeyCurrentUser.Open();
skypePath = RegkeyCurrentUser;
}
Code: Select all
if (RegkeyCurrentUser.Exists())
{
if( RegkeyCurrentUser.Open() )
{
RegkeyCurrentUser.QueryValue("keyname", stkypPath);
}
}
Code: Select all
if (RegkeyCurrentUser.Exists())
{
if( RegkeyCurrentUser.Open() )
{
if( RegkeyCurrentUser.HasValue("keyname") )
{
RegkeyCurrentUser.QueryValue("keyname", stkypPath);
}
}
}
CG
Now it seems to work. the folowing snippet checks whether Skype is installed and if it is, then skype gets started:
Code: Select all
bool res = false;
wxString skypePath;
wxString regPath(wxT("Software\\Skype\\Phone"));
wxRegKey key(wxRegKey::HKCU, regPath);
if (key.Exists())
{
res = key.QueryValue(wxT("SkypePath"), skypePath);
}
else
{
regPath = wxT("Software\\Skype\\Phone");
wxRegKey key(wxRegKey::HKLM, regPath);
if (key.Exists())
{
res = key.QueryValue(wxT("SkypePath"), skypePath);
}
}
if (res) wxExecute(skypePath);