请教高手:我用::WinExec("C:\\\\11\\xx.exe",SW_SHOW);调用了一个由MATLAB生成的文件xx.exe,是绘图的,但是CMD窗口闪了一下后就消失了,没有汇出图。(单独执行xx.exe是可以的)
     然后我做了一个批处理文件,::WinExec("C:\\\\11\\ll.bat",SW_SHOW);ll调用了xx.exe,单独执行也是可以的,但是在VC++6.0调用后显示:'xx.exe' is not recognized as an internal or external command,operable program or batch file.
    请问各位高手:这是为什么?如何修改
     

解决方案 »

  1.   

    别用WinExec函数了。
    用CreateProcess或者ShellExecute还启动新进程。BOOL CreateProcess(
      LPCTSTR lpApplicationName,
      LPTSTR lpCommandLine,
      LPSECURITY_ATTRIBUTES lpProcessAttributes,
      LPSECURITY_ATTRIBUTES lpThreadAttributes,
      BOOL bInheritHandles,
      DWORD dwCreationFlags,
      LPVOID lpEnvironment,
      LPCTSTR lpCurrentDirectory,
      LPSTARTUPINFO lpStartupInfo,
      LPPROCESS_INFORMATION lpProcessInformation
    );HINSTANCE ShellExecute(          HWND hwnd,
        LPCTSTR lpOperation,
        LPCTSTR lpFile,
        LPCTSTR lpParameters,
        LPCTSTR lpDirectory,
        INT nShowCmd
    );
      

  2.   

    按楼上说的函数尝试了下,情况依然相同还是不行期待ING....
      

  3.   

    程序的路径好像是这样吧? C:\\11\\xx.exe 
      

  4.   

    bat文件内容如下:@echo on
    @echo 绘制3维曲面图
    @echo off
    xx.exe
    pause
    单独执行,.BAT和.EXE文件都是可以的。
    我用了相同的调用方式调用了WAR3.EXE也是可以的,但就是xx.exe不可以。
    调用.BAT,是可以执行的,但是却说:'xx.exe' is not recognized as an internal or external command,operable program or batch file. 
    是不是控制台程序调用不行啊.
      

  5.   

    试试使用命令行来启动:"cmd.exe /k C:\\11\\xx.exe"
      

  6.   

    不是路径的问题啊被调用程序是执行了的。。但是没有执行完好像。我用同样的方式调用了WAR3.EXE,执行没有问题
    调用.BAT文件执行后说:'xx.exe' is not recognized as an internal or external command,operable program or batch file. 但是单独执行.BAT文件是可以的。
      

  7.   

    "cmd.exe /k C:\\11\\xx.exe" 
    这个也不行啊,单独用cmd.exe可以调出控制台,但是加上后面的就连控制台都没有弹出来。。
    不过还是谢谢
    继续等
      

  8.   

    修改.bat文件如下:@echo on
    @echo 绘制3维曲面图
    @echo off
    c://11/xx.exe
    pause
    单独执行可以,VC调用后,控制台中出现╗µ╓╞3╬¼╟·├µ═╝
    Cannot find the directory containing the 'xx' component,
     which is required by this application. Make sure the directory containing
     'xx.ctf' is on your dynamic load library path
     (PATH on Windows, or LD_LIBRARY_PATH on Linux, for example), or your
     application search path (PATH on both Windows and Linux).
    Error initializing CTF Archive
    Press any key to continue . . .
      

  9.   

    在View类擦除背景的响应函数OnEraseBkgnd()中写你的代码,去掉Cview::OnEraseBkgnd();
      

  10.   

    怎么会这么怪异?LZ把xx.exe发我看看....
    也许我能帮你搞定    [email protected]
      

  11.   

    问题解决了。。感谢各位了。。关键问题是我傻
    只要把那个.CTF文件拷进DEBUG下就可以了
      

  12.   


    z这个非常好用,只要路径设置真确。
    我甚至在 xx.exe后面又带了参数,也是可以的。
    示例:
    WinExec("cmd.exe /k D:\\practice\\fefaef\\siftWin32.exe <tmp.pgm>tmp.key", SW_SHOW);