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
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;

}

About these ads

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: