Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Application Data Directory

Status
Not open for further replies.

AtomicChip

Programmer
May 15, 2001
622
0
0
CA
Hi all,

I'm sure there's an easy way of doing this... Is there an Win32 API call to get the path to the application data directory? (i.e. C:\Documents and Settings\dbrecht\Local Settings\Application Data\...)

Thanks in advance.

-----------------------------------------------
"The night sky over the planet Krikkit is the least interesting sight in the entire universe."
-Hitch Hiker's Guide To The Galaxy
 
Code:
TCHAR appDataStr[256];
DWORD strSize = ExpandEnvironmentStrings( "%APPDATA%", appDataStr, 256 );

if ( strSize == 0 )
{
   cout << "ExpandEnvironmentStrings() failed with error code: " << GetLastError() << endl;
}
else if ( strSize > 256 )
{
   cout << "appDataStr buffer is too small!" << endl;
}
 
hi,
each application writes its automatic or user-choosen data
where it wants (where the programmer has decided to write them).

Typically under Doc&Set\UserName\[Local Settings\]Application Data, but many programs (Internet Explorer for some values) write them on registry under HKCU.

In this case you are the programmer and you can write your applicaton data where you want. However, cpjust suggestion
has to be taken on consideration.

Warning that what you write
C:\Documents and Settings\UserName\Local Settings\Application Data\ + SoftwareHouseName\DirX,Y,Z)

is different from what %APPDATA% returns:

C:\Documents and Settings\UserName\Application Data\ + SoftwareHouseName\Dirs U,V,W...

many commercial applications uses both, the first to save temporary files for the current session (things too large to stay in memory, or reports, or cached data) while the second is used to remeber user choises/setting (window size/pos, preferred selections) to re-use next time application is launched.

(looking at your Acrobat reader, you find both)

bye
vittorio
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top