Revision: 13297
Updated Code
at November 4, 2009 11:31 by jimfred
Updated Code
AfxGetApp()->m_pszExeName; // Get the "MyExe" portion of "MyExe.exe". Or, "MyDll" if RunDll32 is used. dllName.Append( ".exe" ); // Now has "MyExe.exe" (or "MyDll.dll"). HMODULE hmod = GetModuleHandle(dllName); CString fullPath; DWORD pathLen = ::GetModuleFileName( hmod, fullPath.GetBufferSetLength(MAX_PATH+1), MAX_PATH); // hmod of zero gets the main EXE fullPath.ReleaseBuffer( pathLen ); // Note that ReleaseBuffer doesn't need a +1 for the null byte.
Revision: 13296
Updated Code
at November 4, 2009 11:30 by jimfred
Updated Code
AfxGetApp()->m_pszExeName; // Get the "MyExe" portion of "MyExe.exe". Or, "MyDll" if RunDll32 is used. dllName.Append( ".dll" ); // Now has "MyDll.dll". HMODULE hmod = GetModuleHandle(dllName); CString fullPath; DWORD pathLen = ::GetModuleFileName( hmod, fullPath.GetBufferSetLength(MAX_PATH+1), MAX_PATH); // hmod of zero gets the main EXE fullPath.ReleaseBuffer( pathLen ); // Note that ReleaseBuffer doesn't need a +1 for the null byte.
Revision: 13295
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at April 17, 2009 18:32 by jimfred
Initial Code
AfxGetApp()->m_pszExeName; // Get EXE name ...or, get path info... // With CString char szAppPath[MAX_PATH] = ""; ::GetModuleFileName(0, szAppPath, MAX_PATH); // get path // Extract name CString strAppName; strAppName = szAppPath; strAppName = strAppName.Right(strAppName.ReverseFind('\\') + 1);
Initial URL
http://www.codeguru.com/forum/showthread.php?t=312468
Initial Description
For C++ MFC applications, this code gets the full path of the application (even if the application is a DLL run with RunDll32).
Initial Title
Get application's full path, MFC, using AfxGetApp()->m_pszExeName, GetModuleHandle and GetModuleFileName
Initial Tags
Initial Language
C++