PDA

View Full Version : reading windows registry



bhogasena
20th January 2009, 14:11
hi,
in my application i have to read the path from windows registry.
for that i have written code like this


QSettings settings("HKEY_LOCAL_MACHINE\\SOFTWARE",QSettings::NativeFormat);
QString keyName = "somename\\appname";
QString installPath=settings.value(keyName).toString();
installPath = installPath + "\\";

but i am not able to get the value of keyname which is in registry

can anyone help me please so that i move further

thank you

jpn
20th January 2009, 14:54
The first impression is that apparently the path is wrong, but what else can we do than guess? It would help us to help you if you would show what's written in the registry and where.

mchara
26th January 2009, 09:26
hi,
I'm not sure if "HKEY_LOCAL_MACHINE\\SOFTWARE" is valid,
HKEY_LOCAL_MACHINE or
HKEY_CURRENT_USER is picked depending on defined Scope.

moreover if you set organization name and application name, all settings will be stored in MAIN_KEY\\Software\\orgName\appName.

I don't know how it works when registry path is given in constructor, but maybe its relative to MAIN_KEY\\Software.

Try to write some unique string to the registry and try to find it in regedit to see where it was actually written.

and when all others will fail - use windows native methods (http://msdn.microsoft.com/en-us/library/ms724875(VS.85).aspx)

jpn
26th January 2009, 09:36
hi,
I'm not sure if "HKEY_LOCAL_MACHINE\\SOFTWARE" is valid,
HKEY_LOCAL_MACHINE or
HKEY_CURRENT_USER is picked depending on defined Scope.

moreover if you set organization name and application name, all settings will be stored in MAIN_KEY\\Software\\orgName\appName.

I don't know how it works when registry path is given in constructor, but maybe its relative to MAIN_KEY\\Software.

Try to write some unique string to the registry and try to find it in regedit to see where it was actually written.

and when all others will fail - use windows native methods (http://msdn.microsoft.com/en-us/library/ms724875(VS.85).aspx)
Hi mchara, sure it's valid, see QSettings - Accessing the Windows Registry Directly for more details.