Results 1 to 7 of 7

Thread: Absolute Path to users "Program Files" on Windows

  1. #1
    Join Date
    Apr 2010
    Posts
    23
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Absolute Path to users "Program Files" on Windows

    Hey everybody,

    I guess there's an easy solution, but google and me together were just not able to figure it out. How can I get the full path to users Program Files, usually "C:\Program Files\"?

    I tried SHGetFolderPath, but it returned a TCHAR wich produced about 200 japanese looking characters behind the program-files-path wich was actually right, but not usable it this way.

    Any suggestions? Thanks,

    MisterIKS

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Absolute Path to users "Program Files" on Windows

    Try the "PROGRAMFILES" environment variable

  3. #3
    Join Date
    Apr 2010
    Posts
    23
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Absolute Path to users "Program Files" on Windows

    That's what I read everywhere, but how can I do that with Qt? Do you mean getenv() ? How can I convert the return value to QString, thats my biggest problem using windows-functions.

  4. #4
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Absolute Path to users "Program Files" on Windows

    Try
    Qt Code:
    1. QString programFilesPath(getenv("PROGRAMFILES"));
    To copy to clipboard, switch view to plain text mode 

  5. #5
    Join Date
    Apr 2010
    Posts
    23
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Absolute Path to users "Program Files" on Windows

    Wow, amazing ;-) That works fine, thanks a lot!

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Absolute Path to users "Program Files" on Windows

    How about using QDesktopServices::storageLocation() with QDesktopServices::ApplicationsLocation?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    Apr 2010
    Posts
    23
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Absolute Path to users "Program Files" on Windows

    That's acually not the C:\Program Files Directory, but yet a nice hint to a function I didn't know.
    Thanks for that!

Similar Threads

  1. Replies: 4
    Last Post: 18th April 2010, 00:37
  2. "Cannot run program "C:\Qt\4.3.3\bin\qmake": file not found
    By PeteH in forum Installation and Deployment
    Replies: 1
    Last Post: 7th February 2009, 00:48
  3. creating a "path" for the menu item
    By roxton in forum Qt Programming
    Replies: 4
    Last Post: 17th January 2009, 16:32
  4. Translation QFileDialog standart buttons ("Open"/"Save"/"Cancel")
    By victor.yacovlev in forum Qt Programming
    Replies: 4
    Last Post: 24th January 2008, 19:05
  5. Replies: 1
    Last Post: 18th August 2006, 13:41

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.