承接专栏《MFC工控项目实例之三theApp变量传递对话框参数》
在调试目录Debug下创建DATA、LIB、TEMP三个文件夹
1、SEAL_PRESSURE.h中添加代码
class CSeatApp : public CWinApp
{
...
public:CString m_Path;CString m_DataPath,m_TempPath,m_LibPath;
...
};
2、SEAL_PRESSURE.cpp中添加代码
CSEAL_PRESSUREApp::CSEAL_PRESSUREApp()
{// TODO: add construction code here,// Place all significant initialization in InitInstanceTCHAR exeFullPath[MAX_PATH];GetModuleFileName(NULL,exeFullPath,MAX_PATH);m_Path = exeFullPath;for(int i = m_Path.GetLength() - 1; i > 0 ; i --){if(m_Path.GetAt(i) == '\\')break;}SetCurrentDirectory(m_Path);m_Path = m_Path.Left(i);m_DataPath = m_Path + "\\DATA\\";m_TempPath = m_Path + "\\TEMP\\";m_LibPath = m_Path + "\\LIB\\"; CreateDirectory(m_LibPath,FALSE);CreateDirectory(m_DataPath,FALSE);CreateDirectory(m_TempPath,FALSE);
}
运行程序