Revision: 13842
Updated Code
at September 29, 2009 15:16 by jimfred
Updated Code
CString sThisDir; // in atlstr.h
::GetModuleFileName( // In WinBase.h.
0, // retrieve path of .exe file for the current process.
sThisDir.GetBufferSetLength(MAX_PATH),
MAX_PATH);
sThisDir.Truncate( sThisDir.ReverseFind('\\') + 1 ); // Chop off the app.exe portion.
// Alternative to create a myApp.ini file name:
CString thisExe; // in atlstr.h
::GetModuleFileName( // In WinBase.h.
0, // retrieve path of .exe file for the current process.
thisExe.GetBufferSetLength(MAX_PATH),
MAX_PATH);
thisExe.Truncate( thisExe.ReverseFind('.') ); // Chop off the .exe.
CString iniFile = thisExe;
iniFile.Append( ".ini" ); // Replace .exe with .ini.
// I didn't use CString::Replace because there could be multiple embedded ".exe" in the path.
// I found that Vista wanted to store INIs in the Windows directory rather than the CWD.
Revision: 13841
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at May 7, 2009 15:35 by jimfred
Initial Code
CString sThisDir; // in atlstr.h
::GetModuleFileName( // In WinBase.h.
0, // retrieve path of .exe file for the current process.
sThisDir.GetBufferSetLength(MAX_PATH),
MAX_PATH);
sThisDir.Truncate( sThisDir.ReverseFind('\\') + 1 ); // Chop off the .exe name.
Initial URL
Initial Description
Determine directory where the .exe is running from. Usually it's CWD - but not always, such as MsiExec Custom Actions. Windows. non-dot.net, with or without MFC.
Initial Title
Get my exe's directory. WinBase API
Initial Tags
windows
Initial Language
C++