Get application root path in VC++

Wanna get application root path from vc++? You have to follow the following code:

in your application header file

// Implementation
CString m_strCurrentDirName;

In application cpp file:

BOOL VMCLEScannerGameBookApp::InitInstance()

/*** Get Application Root path ***/
CString strDir;

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;



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: