Where should my win32 program keep its files?

后端 未结 8 1498
时光取名叫无心
时光取名叫无心 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 06:05

    For your application binaries, you can assume that you may write to the PROGRAM FILES directory (use the %ProgramFiles% environment variable to support installations other than the default English version - e.g. in german Installations this will be c:\Programme by default). Wikipedia lists the most common variables. Another option are the SHGetFolderPath or newer SHGetKnownFolderPath functions.

    For User data, you should assume that the application is running with limited access rights and may only write to the user's home directory. Same applies for registry entries. This path should probably be configurable b the user, as the home directory may actually be a network server and a user might have a second disk attached for data storage. For information on the current (Vista) filesystem guidelines see this article.

    Regarding plugins, this might be more complicated. The best practice seams to be offering the option to install for the current user only, and placing the plugin in the user directory, or install for all users and place the files into your program files directory (but remember to check for write permission and request elavated access if needed).

提交回复
热议问题