运行外部exe
bool CFileOperate::lauchCAD() { //启动ZWCAD CString OutputPath; STARTUPINFO si; //一些必备参数设置 memset(&si, 0, sizeof(STARTUPINFO)); si.cb = sizeof(STARTUPINFO); si.dwFlags = STARTF_USESHOWWINDOW; si.wShowWindow = SW_SHOWNORMAL; PROCESS_INFORMATION pi; //必备参数设置结束 OutputPath = m_strCADPath + _T("acad.exe"); BOOL bRet = CreateProcess(NULL,OutputPath.GetBuffer(OutputPath.GetLength()),NULL,NULL,FALSE,0,NULL,NULL,&si,&pi); return bRet; }
bool CheckPass() { #ifdef _NCHECK return true; #endif wchar_t buffer[MAX_PATH]; DWORD code = GetEnvironmentVariable(L"JDC_PROTAL", buffer, MAX_PATH); if (code == 0) { AfxMessageBox(_T("权限校验失败!")); return false; } CString sPath; sPath.Format(_T("%s"), buffer); sPath += _T("\\Manage\\CheckPass.exe"); SHELLEXECUTEINFO ShExecInfo = { 0 }; ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO); ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS; ShExecInfo.hwnd = NULL; ShExecInfo.lpVerb = NULL; ShExecInfo.lpFile = sPath; ShExecInfo.lpParameters = _T("-Module:电缆装配图电路图接线图快速设计 -AD"); ShExecInfo.lpDirectory = NULL; ShExecInfo.nShow = SW_SHOW; ShExecInfo.hInstApp = NULL; BOOL b = ShellExecuteEx(&ShExecInfo); DWORD dwExitCode=0; DWORD dwResult = WaitForSingleObject(ShExecInfo.hProcess, INFINITE); b=GetExitCodeProcess(ShExecInfo.hProcess, &dwExitCode); b = CloseHandle(ShExecInfo.hProcess); if (dwExitCode==29) { return true; } else { // AfxMessageBox(_T("权限校验失败!")); return false; } }