Application Data Folder

Started by
2 comments, last by Bugdude 19 years, 8 months ago
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?
Advertisement
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 == '\\' )  //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
Quote:Original post by ace_lovegrove
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 '//'


that's for '\' not '/'

Matt

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.

This topic is closed to new replies.

Advertisement