SHELLEXECUTEINFO ShExecInfo = {0};
ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
ShExecInfo.hwnd = NULL;
ShExecInfo.lpVerb = "open";

ShExecInfo.lpFile = "\\Myprogramme\\Myprogramme.exe";
ShExecInfo.lpParameters ="";
ShExecInfo.lpDirectory = "\\Myprogramme\\";
ShExecInfo.nShow = SW_SHOW;
ShExecInfo.hInstApp = NULL;
ShellExecuteEx(&ShExecInfo);我想用相对路径,也就是执行当前路径下Myprogramme下的程序,怎么老师报路径错呢??

解决方案 »

  1.   

    用GetCurrentDirectory看看你的当前路径是不是你需要的。
      

  2.   

    楼上说的对,调试是的默认模块路径是工程路径,可能是你路径处理的问题,如果你在浏览器中启动应用就可能正确了(不用IDE启动)。
      

  3.   

    char szCurPath[200];      
             memset(szCurPath, 0, 200);

              GetCurrentDirectory( 100, szCurPath );//method 1
    //GetModuleFileName(NULL, szCurPath, sizeof(szCurPath));//method 2        strcat(szCurPath, "\\Myprogramme.exe");把ShExecInfo.lpFile = "\\Myprogramme\\Myprogramme.exe";
    改成ShExecInfo.lpFile = szCurPath;
      

  4.   

    检查一下路径,用绝对路径
    CString GetAppPath()
    {
    char exepath[MAX_PATH];
    CString strdir, tmpdir; memset(exepath, 0, MAX_PATH); GetModuleFileName(NULL, exepath, MAX_PATH);
    tmpdir = exepath;
    strdir = tmpdir.Left(tmpdir.ReverseFind('\\')); return strdir;
    }
    以上的函数可以得到运行路径