Where should my win32 program keep its files?

后端 未结 8 1602
时光取名叫无心
时光取名叫无心 2021-02-08 05:19

Our win32 applications (written in C++) have been around for over 10 years, and haven\'t been updated to follow \"good practices\" in terms of where they keep files. The applica

8条回答
  •  青春惊慌失措
    2021-02-08 05:54

    Presumably, it's "best practices" to default to installing under "c:\Program Files\AppName"

    Close, but not quite. Users can configure the name of the Program Files folder and may not even have a C: drive. Instead, install to the %ProgramFiles%\AppName environment variable folder. Note that you should assume you only have read access to this folder after the installation has finished.

    For program data files where you might need write access, use %AppData%\AppName.

    Finally, are you sure yours is the only app with that name? If you're not 100% certain of that, you might want to include your company name in there as well.

    The mechanisms you use to retrieve those variables will vary depending on your programming platform. It normally comes down to the SHGetFolderPath() Win32 method in the end, but different platforms like Java or .Net may provide simpler abstractions as well.

提交回复
热议问题