MFC调用exe

方法一、(进程方式)
STARTUPINFO    si;
PROCESS_INFORMATION    pi;
ZeroMemory(    &si,    sizeof(si)    );
si.cb    =    sizeof(si);
ZeroMemory(    &pi,    sizeof(pi)    );
if(    !CreateProcess(             NULL, "E;\Test.exe ",NULL,NULL,FALSE,CREATE_NO_WINDOW,NULL,NULL,&si,&pi    )       )  
{
            MessageBox( "出错 ", "提示 ",MB_OK|MB_ICONINFORMATION);
}
WaitForSingleObject(    pi.hProcess,    INFINITE    );
CloseHandle(    pi.hProcess    );
CloseHandle(    pi.hThread    );
方法二、(线程方式)
WinExec( "Test.Exe ",    SW_HIDE);

Q:  如何打开一个应用程序?
ShellExecute(this->m_hWnd,"open","calc.exe","","",  SW_SHOW  );

ShellExecute(this->m_hWnd,"open","notepad.exe",
        "c:\\MyLog.log","",SW_SHOW  );
As  you  can  see,  haven't  passed  the  full  path  of  the  programs. 
 
Q:  如何打开一个同系统程序相关连的文档?
ShellExecute(this->m_hWnd,"open",
        "c:\\abc.txt","","",SW_SHOW  );
 
Q:  如何打开一个网页?
ShellExecute(this->m_hWnd,"open",
        "http://www.google.com","","",  SW_SHOW  );
 
Q:  如何激活相关程序,发送EMAIL?
ShellExecute(this->m_hWnd,"open",
        "mailto:[email protected]","","",  SW_SHOW  );
 
Q:  如何用系统打印机打印文档?
ShellExecute(this->m_hWnd,"print",
        "c:\\abc.txt","","",  SW_HIDE);
 
Q:  如何用系统查找功能来查找指定文件?
ShellExecute(m_hWnd,"find","d:\\nish",
        NULL,NULL,SW_SHOW);

你可能感兴趣的:(MFC调用exe)