Sign in to follow this  

Application Data Folder

This topic is 4867 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
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 this post


Link to post
Share on other sites
Guest Anonymous Poster
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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

This topic is 4867 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this