zoukankan      html  css  js  c++  java
  • 运行外部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;
        }
        
    }
  • 相关阅读:
    跨浏览器的事件处理程序
    开发技术文档汇总
    JVM知识树
    JDK1.8新特性(一)
    CAS
    Redis集群之修改节点IP
    阿里云服务器 发送邮箱 STMP 25端口 465端口问题 Javamail 25被禁用
    日志log4j到Logback的使用(主要是Logback)
    ThreadLocal原理和 java类全局静态变量在多线程中数据混乱问题
    SpringMVC拦截器拦截页面(坑)
  • 原文地址:https://www.cnblogs.com/xzh1993/p/10563762.html
Copyright © 2011-2022 走看看