Results 1 to 4 of 4

Thread: Save log file to "all user\application data\"

  1. #1
    Join Date
    Jul 2008
    Location
    Munich
    Posts
    73
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Exclamation Save log file to "all user\application data\"

    My application has some configuration file and log file to store.

    Q1:
    In winxp, i want to save them to "C:/Documents and Settings/All Users/Application data/". I have no idea how to get this location using qt.

    Q2:
    And in win7, the file structure is different. I am not sure whether the directory should be "C:/Program data".

    Q3:
    I don't think there is any log data can be written to global location in Linux. Right?

    Any one can help?

  2. #2
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Save log file to "all user\application data\"

    Check the Microsoft requirements on MSDN. Eg for Windows 7:

    "All application data that must be shared among users on the computer should be stored within ProgramData. All application data exclusive to a specific user and not to be shared with other users of the computer must be stored in Users\<username>\AppData."

    As for where the directories are, check out QDesktopServices::storageLocation

  3. #3
    Join Date
    Mar 2011
    Location
    Russia, Lipetsk
    Posts
    17
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Save log file to "all user\application data\"

    I used in my project It is:

    Qt Code:
    1. QDir::homePath()
    To copy to clipboard, switch view to plain text mode 

    In Win XP it is C:/Documents and Settings/%USERNAME%/
    In win 7 C:/Users/<username>/

  4. #4
    Join Date
    Jul 2008
    Location
    Munich
    Posts
    73
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Save log file to "all user\application data\"

    Quote Originally Posted by squidge View Post
    Check the Microsoft requirements on MSDN. Eg for Windows 7:

    "All application data that must be shared among users on the computer should be stored within ProgramData. All application data exclusive to a specific user and not to be shared with other users of the computer must be stored in Users\<username>\AppData."

    As for where the directories are, check out QDesktopServices::storageLocation
    Thanks.

    But QDesktopServices::storageLocation doesn't support "all users\appdata", but only for current user.

    For example:
    ini_path = QDesktopServices::storageLocation(QDesktopServices :ataLocation);
    gives "<username>\local settings\AppData".

    PS:
    ini_path = getenv("ProgramData"); // "<username>\AppData".
    ini_path = getenv("ALLUSERSPROFILE"); // "all users\".

    But I need exactly "all users\appdata".


    Added after 1 2 minutes:


    I found the solution:
    Qt Code:
    1. QSettings register("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders", QSettings::NativeFormat);
    2. QString allUserDesktop( register.value("Common AppData").toString());
    To copy to clipboard, switch view to plain text mode 

    Last edited by stella1016; 4th July 2011 at 16:01.

Similar Threads

  1. Replies: 8
    Last Post: 5th November 2012, 08:43
  2. Replies: 6
    Last Post: 16th June 2011, 13:20
  3. Replies: 3
    Last Post: 15th February 2010, 17:27
  4. Replies: 3
    Last Post: 8th July 2008, 19:37
  5. Translation QFileDialog standart buttons ("Open"/"Save"/"Cancel")
    By victor.yacovlev in forum Qt Programming
    Replies: 4
    Last Post: 24th January 2008, 19:05

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.