/ Published in: C++
For C++ MFC applications, this code gets the full path of the application (even if the application is a DLL run with RunDll32).
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
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.
URL: http://www.codeguru.com/forum/showthread.php?t=312468