PDA

View Full Version : Getting your program's filename



Raptisoft
11-12-2004, 05:19 PM
Hi all,

Sort of a dumb question, but I can't seem to type in the right combination of keywords to bring up an answer on Google. :)

I want to know what my program's filename is. I.E. you run THEGAME.EXE, I know that somewhere, there's a function call that will tell me "THEGAME.EXE"

Anyone know what it is?

Thanks!

Jason Chong
11-12-2004, 05:31 PM
In ansi C/C++ it would be argv[0]


For win32, look up

DWORD GetModuleFileName(

HMODULE hModule, // handle to module to find filename for
LPTSTR lpFilename, // pointer to buffer for module path
DWORD nSize // size of buffer, in characters
);

Raptisoft
11-12-2004, 06:07 PM
Ah, thank you, GetModuleFilename was it.