方法一、(进程方式)
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, I 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:nishinapp@yahoo.com","","", SW_SHOW );
Q: 如何用系统打印机打印文档?
ShellExecute(this->m_hWnd,"print",
"c:\\abc.txt","","", SW_HIDE);
Q: 如何用系统查找功能来查找指定文件?
ShellExecute(m_hWnd,"find","d:\\nish",
NULL,NULL,SW_SHOW);
STARTUPINFO
PROCESS_INFORMATION
ZeroMemory(
si.cb
ZeroMemory(
if(
{
}
WaitForSingleObject(
CloseHandle(
CloseHandle(
方法二、(线程方式)
WinExec( "Test.Exe ",
Q:
ShellExecute(this->m_hWnd,"open","calc.exe","","",
或
ShellExecute(this->m_hWnd,"open","notepad.exe",
As
Q:
ShellExecute(this->m_hWnd,"open",
Q:
ShellExecute(this->m_hWnd,"open",
Q:
ShellExecute(this->m_hWnd,"open",
Q:
ShellExecute(this->m_hWnd,"print",
Q:
ShellExecute(m_hWnd,"find","d:\\nish",
Windows应用启动方法
本文介绍了在Windows环境下通过不同API启动应用程序、文档及网页的方法。包括使用CreateProcess、WinExec及ShellExecute等函数的具体实例。
1933

被折叠的 条评论
为什么被折叠?



