Results 1 to 4 of 4

Thread: reading windows registry

  1. #1
    Join Date
    Jan 2009
    Posts
    33
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default reading windows registry

    hi,
    in my application i have to read the path from windows registry.
    for that i have written code like this

    Qt Code:
    1. QSettings settings("HKEY_LOCAL_MACHINE\\SOFTWARE",QSettings::NativeFormat);
    2. QString keyName = "somename\\appname";
    3. QString installPath=settings.value(keyName).toString();
    4. installPath = installPath + "\\";
    To copy to clipboard, switch view to plain text mode 

    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
    Last edited by jpn; 20th January 2009 at 14:49. Reason: missing [code] tags

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: reading windows registry

    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.
    J-P Nurmi

  3. #3
    Join Date
    Sep 2007
    Location
    Szczecin, Poland
    Posts
    153
    Thanks
    7
    Thanked 11 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: reading windows registry

    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/libr...75(VS.85).aspx)
    See GrEEn (Graphics Effects Environment)
    http://sourceforge.net/project/platf...roup_id=232746
    a qt-based plugins oriented MDI image processing application(contains also qt plugins like styles & imageformats).

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: reading windows registry

    Quote Originally Posted by mchara View Post
    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/libr...75(VS.85).aspx)
    Hi mchara, sure it's valid, see QSettings - Accessing the Windows Registry Directly for more details.
    J-P Nurmi

Similar Threads

  1. Replies: 1
    Last Post: 19th September 2008, 15:43
  2. reading from registry
    By phillip_Qt in forum Newbie
    Replies: 11
    Last Post: 26th October 2007, 06:49
  3. QWT 5, QT3, SuSE 10.2. Crash and burn
    By DrMcCleod in forum Qwt
    Replies: 8
    Last Post: 7th September 2007, 20:53
  4. Accessing Windows Registry
    By musaulker in forum Newbie
    Replies: 1
    Last Post: 29th March 2007, 00:32

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.