theApp. m_AppPath 应用程序当前路径
void CClientWorkSpaceApp::ConfigGetAppPath()
{
TCHAR path[MAX_PATH];
memset(path,0,sizeof(TCHAR)*MAX_PATH);
GetModuleFileName( NULL,path, MAX_PATH );
TCHAR drive[MAX_PATH],dir[MAX_PATH],fname[MAX_PATH],ext[MAX_PATH];
_tsplitpath(path,drive,dir,fname,ext );
m_AppPath = drive;
m_AppPath += dir;
}
<Environment.h>
#pragma once
class CEnvironment
{
public:
CEnvironment(void);
~CEnvironment(void);
static CString ConfigGetAppDir(void);
static int Init(void);
static CString m_AppPath;
static CString m_AppDriver;
static CString m_AppDir;
static CString m_AppFileName;
static CString m_AppFileExt;
};
<Environment.cpp>
#include "StdAfx.h"
#include "Environment.h"
CString CEnvironment::m_AppPath = _T("");
CString CEnvironment::m_AppDriver = _T("");
CString CEnvironment::m_AppDir = _T("");
CString CEnvironment::m_AppFileName = _T("");
CString CEnvironment::m_AppFileExt = _T("");
CEnvironment::CEnvironment(void)
{
}
CEnvironment::~CEnvironment(void)
{
}
int CEnvironment::Init(void)
{
if (_T("")!=m_AppDriver)
return 0;
TCHAR path[MAX_PATH];
memset(path,0,sizeof(TCHAR)*MAX_PATH);
GetModuleFileName( NULL,path, MAX_PATH );
TCHAR drive[MAX_PATH],dir[MAX_PATH],fname[MAX_PATH],ext[MAX_PATH];
_tsplitpath(path,drive,dir,fname,ext );
m_AppDriver = drive;
m_AppDir = dir;
m_AppFileName = fname;
m_AppFileExt = ext;
//m_AppPath = drive;
return 1;
}
CString CEnvironment::ConfigGetAppDir(void)
{
Init();
return m_AppDriver+m_AppDir;
//m_AppPath = drive;
//m_AppPath += dir;
}