I have made an installer (using Inno Setup) for my software, which is finally installed in
C:\\Program Files (x86)\\MyApp\\myapp.exe
as usual o
As @TLama said, never ever try to write to the application folder. That was never the recommended practice and since Vista Microsoft has disabled it (by first allowing you to write but actually redirecting the writing to another directory, a functionality which in later OS versions seems to have been removed - and good thing too as it was making support hellish).
To retrieve a known folder path, use SHGetFolderPath function. Depending on whether the application data is shared among all users or just used by the user running the app, you should call SHGetFolderPath
either with CSIDL_COMMON_APPDATA or with CSIDL_LOCAL_APPDATA respectively. Avoid writing directly in those folders but create subfolders like
and use those instead.
Note that SHGetFolderPath
has been deprecated and SHGetKnownFolderPath should be used in lieu of it but only if you don't need compatibility with Windows versions prior to Vista.
For completeness sake, this thread also describes how to import SHGetFolderPath
into Python.
Update: Corrected to avoid using environment variables and SHGetFolderPath
instead per comments by @RemyLebeau @TLama