View Single Post
Old 04-17-2005, 03:33 PM   #1 (permalink)
enemite
Registered User
 
Join Date: Sep 2004
Posts: 2
enemite is on a distinguished road
Send a message via AIM to enemite Send a message via MSN to enemite Send a message via Yahoo to enemite
Question get/change current directory in windows

I'm working on a flashcard program, and after you load a file and go through the drill, it will write your score/time to a text file. I also have a menu item that loads the text file with notepad like this:

ShellExecute(NULL, "open", "stats.txt", NULL, NULL, SW_NORMAL);

So after you have completed the flashcard set, it will write it to stats.txt file and then you can load it through the menu afterwards (and it's in the same directory as the file you have loaded).

But if you start the program and don't load a file and try to load the stats, it won't do anything because the current directory is still where the program itself is. And the stats you're trying to load are scattered wherever the cardset files are!

What I want to do write the stats file to the same directory the program itself is in so that it can always be loaded. And so there won't be a bunch of text files everywhere. Also it appends the stats to the same file so you can monitor your progress.

Looking at the prototype for ShellExecute() one of the parameters is for the default directory, but how do I change it and set it?

Is there a function to get the current directory the program is using?
And is there a function to change the current directory the program is using?

I've tried searching the web for info, but all I can find is help for VB, and I'm using C/C++. Can anyone help? And please go easy on me, it's my first post.
enemite is offline   Reply With Quote