Where to best store app data on Windows

Thijs Koerselman's icon

For a standalone app I need to store some external data, so it's not overwritten when the app is updated or replaced with a new version.

On OSX this is straightforward. I just write stuff to ~/Library/Application Support/Myapp. I am pretty safe to assume that I have permissions to create that directory and write things in it.

On Windows I'm not sure about this. I haven't used the platform for ages but afaik there is "Program Files" but also possibly "Program Files x86_64" or something. And it is typically located on C:/ but it could be any other drive.

What would be a sensible approach? Are there any helper functions in Max or the SDK that can be used figure out a location on any Windows system that won't get me into trouble?

Thijs Koerselman's icon

I found some standard W32 api. Makes sense to use that straight from my code. I wasn't thinking clearly :)

TCHAR pf[MAX_PATH];
SHGetSpecialFolderPath(
0,
pf,
CSIDL_PROGRAM_FILES,
FALSE );

Emmanuel Jourdan's icon

IMHO, on a multi-user machine CSIDL_APPDATA would probably be better.

Thijs Koerselman's icon

Thanks for the advice Emmanuel. I'll try that.