Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QStandardPaths and CSIDL_COMMON_APPDATA



  • I'm somewhat bothered by an apparent omission from QStandardPaths

    There doesn't appear to be one that will return me the equivalent of

    SHGetFolderPath(nullptr, CSIDL_COMMON_APPDATA, nullptr, SHGFP_TYPE_CURRENT, szPath);
    

    which will return the location of the ProgramData directory which is the location where the public settings should be stored.

    The only one that is close is QStandardPaths::ConfigLocation but AFAICT, using

    QStandardPaths::writeableLocation(QStandardPaths::ConfigLocation)
    

    will typically return C:/Users/<USER>/AppData/Local which is the per user location, rather than %SystemDrive%/ProgramData.

    David



  • I've considered this and have decided to use the per user location ...

    Thanks folks.


  • Lifetime Qt Champion

    Hi,

    AFAIK, that class is mainly for user centered path. The path you describe is likely read only unless you are an admin, isn't it ?



  • No, not at all. It is very common for the permissions on the <APPNAME> sub-folders of ProgramData to be set by installation programs such that they are writeable by members of the "Users" group.

    So it is a "system wide" settings location but it is very commonly user writeable.

    I can accept that perhaps user applications should reserve the <APPNAME> sub-folders of ProgramData (%ALLUSERSPROFILE%) for "system wide" settings created by their installer, but historically that wasn't how it was typically used (right or wrong).

    I'm not totally averse to changing the code to use the "per user" location in the future, but to do so would create a non-trivial incompatibility with the earlier (non Qt) releases.



  • The default value (writableLocation) of ConfigLocation is "C:/Users/<USER>/AppData/Local/<APPNAME>"
    But you should be able to get "C:/ProgramData/<APPNAME>" from the strings returned from standardLocations, probably the second one.
    Or "C:/ProgramData" from the second string of standardLocations(GenericConfigLocation).



  • I've considered this and have decided to use the per user location ...

    Thanks folks.


Log in to reply