Wanna get application root path from vc++? You have to follow the following code:
in your application header file
// Implementation
public:
CString m_strCurrentDirName;
In application cpp file:
BOOL VMCLEScannerGameBookApp::InitInstance()
{
/*** Get Application Root path ***/
CString strDir;
GetModuleFileName(NULL,
strDir.GetBufferSetLength(MAX_PATH),
MAX_PATH);
int nLen = strDir.ReverseFind(‘\\’);
m_strCurrentDirName = strDir.Left(nLen + 1);
VMCLEScannerGameBookDlg dlg;
m_pMainWnd = &dlg;
dlg.m_strCurrentDir = m_strCurrentDirName; // Set Root Path to the MainWindow
int nResponse = dlg.DoModal();
// Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application’s message pump.
return FALSE;
}
Filed under: VC++ Tagged: | application path, current directory, root directory, VC++




