在VC 编程中我想编写一段可启动另一个应用程序的代码。我记得曾看过的,可惜又忘了,请问有哪位知道?是用哪个方法还是哪个类?

解决方案 »

  1.   

    WinExec("\"C:\Program Files\MyApp.exe\" -L -S", ...)
    WinExec
    The WinExec function runs the specified application. Note  This function is provided only for compatibility with 16-bit Windows. Applications should use the CreateProcess function. UINT WinExec(
      LPCSTR lpCmdLine,  // command line
      UINT uCmdShow      // window style
    );
    Parameters
    lpCmdLine 
    [in] Pointer to a null-terminated character string that contains the command line (file name plus optional parameters) for the application to be executed. If the name of the executable file in the lpCmdLine parameter does not contain a directory path, the system searches for the executable file in this sequence: 
    The directory from which the application loaded. 
    The current directory. 
    The Windows system directory. The GetSystemDirectory function retrieves the path of this directory. 
    The Windows directory. The GetWindowsDirectory function retrieves the path of this directory. 
    The directories listed in the PATH environment variable. 
    uCmdShow 
    [in] Specifies how a Windows-based application window is to be shown and is used to supply the wShowWindow member of the STARTUPINFO parameter to the CreateProcess function. For a list of the acceptable values, see the description of the nCmdShow parameter of the ShowWindow function. For a non-Windows – based application, the PIF file, if any, for the application determines the window state. 
      

  2.   

    WinExec("C:\Program Files\MyApp", ...) 
      

  3.   

    那么,能说一下WinExec()中第二个参数的具体常用的参数有哪些吗?而这些参数具体作用又是什么。
       谢谢了。
      

  4.   

    以下使用CreateProcess------STARTUPINFO StartupInfo;
     PROCESS_INFORMATION ProcessInfo;
     memset(&StartupInfo,0,sizeof(STARTUPINFO));
     StartupInfo.cb=sizeof(STARTUPINFO);
     StartupInfo.dwFlags=STARTF_USESHOWWINDOW;
    StartupInfo.wShowWindow=SW_SHOWMINIMIZED;
    ::CreateProcess(NULL,"c:\\Program Files\\Microsoft Office\\Office\\WINWORD.exe",NULL,NULL,FALSE,0,
              NULL,NULL,&StartupInfo,&ProcessInfo);
     return;