Click to See Complete Forum and Search --> : getting a program's installation directory


jarro_2783
April 28th, 2007, 09:47 PM
If I start a program from a directory other than the executables actual folder how can I access the path that it's actually installed in?

eg.
c:\> c:\programming\myprogram\myprogram

CurrentDirectory will now give me c:\, and any calls to std::ifstream::open will be relative to c:\ and I won't be able to access dlls and other resource files that I might want to load which are in the same folder as my executable.
How do I do this?

VladimirF
April 29th, 2007, 01:13 AM
Check out GetModuleFileName()

jarro_2783
April 29th, 2007, 02:31 AM
awesome, that's exactly what I wanted, thanks.