Application Data Folder

Recommended Posts

I want to store my game options and saves in the Application Data folder in windows. (2K/XP: c:/documents and settings/user/Application Data). I looked at VC documentation and I am still confused. What is the difference between SHGetSpecialFolderPath and SHGetSpecialFolderLocation ? Both functions take an HWND as a param. MSDN: Handle to the owner window the client should specify if it displays a dialog box or message box. In what situation would the function display a message box? Also, if I get the app data folder under windows 95/98 what path will I get?

Share on other sites
i may be able to help...

If you want to get the current directory u can do this...

	int     i;	char	CurrentDirPath[260];	char	OrigDirPath[260];	GetModuleFileName(NULL, &CurrentDirPath[0], sizeof (CurrentDirPath));	for( i = strlen(&CurrentDirPath[0])-1 ; i >= 0 ; i-- )	{		if( CurrentDirPath[i] == '\\' )  //find the last backslash in the		{                        //module filename			CurrentDirPath[i+1]=NULL; //set the byte after it to NULL to 			break;		}	}	strcpy(&OrigDirPath[0], &CurrentDirPath[0]);

Then if you want to move to a specific dir in the current directory u can just use some strcat() functions to build teh dir path, dont forget that in order to have a slash '/'in a string u have to use '//'

hope this helps

ace

Share on other sites
Quote:
 Original post by ace_lovegroveThen if you want to move to a specific dir in the current directory u can just use some strcat() functions to build teh dir path, dont forget that in order to have a slash '/'in a string u have to use '//'

that's for '\' not '/'

Matt

Share on other sites
Well according to the MSDN, SHGetSpecialFolderPath() returns the path in a LPCSTR where as SHGetSpecialFolderLocation() returns a ITEMIDLIST. But the function you really want is SHGetFolderPath()—It is the superset of SHGetSpecialFolderPath().

To use SHGetFolderPath() on machines that don't have version 5.0 of shell32.dll (i.e., don't have IE5 or better) you will need to distribute SHFolder.dll with your application. A SHFolder redistributable is available in the Platform SDK.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

• Forum Statistics

• Total Topics
627701
• Total Posts
2978708

• 21
• 14
• 12
• 10
• 12