Proper use of the Windows user profile directory

I need to create a directory in the Windows users home directory ( c:\Documents and Settings\someusername\or c:\users\someusername\). This directory will exist permanently, but will only contain temporary files.

What is the best place for this directory in the user profile if I want to be a good citizen? I should note that my program will be executed (possibly) by non-administrative users and will have access only to their own profile, but they must have permission to create a folder.

Use is My Documents\NameOfMyApp\possible, I think, but it seems intrusive.

Is there a better location for this data type and a specific MFC call to access it?

+3
source share
3 answers

I would consider using the AppData directory. You can get its location SHGetSpecialFolderLocationby passing it CSIDL_APPDATA; (or several alternatives - almost every version of Windows adds a new replacement for SHGetSpecialFolderLocation, SHGetSpecialFolderPathor (often) both).

+4
source

Take a look at the following win32 calls:

You probably want to use GetUserProfileDirectory and put your data in a subdirectory with your application name.

, "\ " Vista , "\ user".

+1

, : []:\Documents and Settings [ ]\ [AppName] []:\Documents and Settings [ ]\ \ [AppName] ( Vista Win7 " " "" )

USERPROFILE , , . TEMP

, C:\temp

EDIT: , (USERPATH XP 2000), .

-Waldo

PS Thank you for asking about this. I see Waaaay misbehaving too many applications. C root: not where you have to dump things! At least (check availability by creating if necessary, and) use C: \ Temp.

0
source

Source: https://habr.com/ru/post/1761389/


All Articles