Q: How to get the application name?
A: If this is a MFC application you could do
Code:
AfxGetApp()->m_pszExeName;
In all other cases the function 'GetModuleFileName()' can be used...
Code:
// With STL string
#include <string>
char szAppPath[MAX_PATH] = "";
std::string strAppName;
::GetModuleFileName(0, szAppPath, MAX_PATH);
// Extract name
strAppName = szAppPath;
strAppName = strAppName.substr(strAppName.rfind("\\") + 1);
// With CString
char szAppPath[MAX_PATH] = "";
CString strAppName;
::GetModuleFileName(0, szAppPath, MAX_PATH);
// Extract name
strAppName = szAppPath;
strAppName = strAppName.Right(strAppName.ReverseFind('\\') + 1);