How can I change the dir the program is using, in windows. (ie what is the windows equivelant of system("c:\\dir\\to\\change\\to). Also how can I figure out the folder that the program is in?
How can I change the dir the program is using, in windows. (ie what is the windows equivelant of system("c:\\dir\\to\\change\\to). Also how can I figure out the folder that the program is in?
You can change the surrent directory with chdir(), and GetModuleFileName() will return the full path of the current module. Look them up in the help.
Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.
For wanting to know the program's current directory, you'll want to get the handle of the program:
HINSTANCE hInstance = GetModuleHandle(NULL);
Now you have the handle of the program. (This is kinda funny because the program is passing itself its own handle).
I don't know what you want to do with it but you could do something creative like print out the directory:
This will print out the directory that the program is running from.Code:char szFileName[MAX_PATH]; HINSTANCE hInstance = GetModuleHandle(NULL); GetModuleFileName(hInstance, szFileName, MAX_PATH); MessageBox(hwnd, szFileName, "This program is:", MB_OK | MB_ICONINFORMATION);
Not sure how to change directories though... depends on what you want to do by changing directories, I guess.
Thanks guys
There is also
GetCurrentDirectory()
and
SetCurrentDirectory()
"Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
Friedrich Nietzsche
"I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
George Best
"If you are going through hell....keep going."
Winston Churchill
Whoa - cool, thanks novocain!
Newbie myself, don't know all the functions there are....