1

The question is related to the Title: Windows 7: Can't save files to Program Files? So where to write?

I know that there is a AppData, but I don't know how to obtain the directory correclty? Is there an API to get it?

Do this API get the AppData for Windows XP too?

nobody
  • 19,814
  • 17
  • 56
  • 77
okami
  • 2,093
  • 7
  • 28
  • 40

1 Answers1

2

ShGetFolderPath (..., CSIDL_APPDATA, ..., ..., ...);

Yes this works on XP too. You should never use hard coded paths in applications.

http://msdn.microsoft.com/en-us/library/bb762181(VS.85).aspx

Update: As Steve Townsend pointed out, this API is deprecated starting with Vista. You should use SHGetKnownFolderPath if you target an OS > XP.

Simon H.
  • 541
  • 4
  • 11
  • MSDN says that API is deprecated, you should edit your answer and URL to use the one it indicates you should prefer, on later versions of Windows. – Steve Townsend Nov 02 '10 at 17:15