(VC++编程中)运行exe文件的API函数是哪些

想用MFC做一个异形登陆器,之后运行一个EXE文件... 想用MFC做一个异形登陆器,之后运行一个EXE文件 展开
 我来答
匿名用户
推荐于2016-12-04
展开全部
最简单的办法:
Winexec(filename,SW_Show);
稍微难一点的CreateProcess(),创建进程
给楼主个例子
CString str;
STARTUPINFO si;
PROCESS_INFORMATION pi;

// 调用的应用程序名
str = "Ping"; //"Ping.exe"

// zero out and initialize STARTUPINFO
memset( &si, 0, sizeof( si ) );
si.cb = sizeof( si );
si.dwFlags = STARTF_USESHOWWINDOW;
si.wShowWindow = SW_SHOW;
if(CreateProcess(
NULL, // can be name of process unless
// batch file, else must be
// in command line:
(char*)LPCSTR(str), // command line
NULL,NULL, // security options
FALSE, // if true will inherit all
// inheritable handles
// from this process
NORMAL_PRIORITY_CLASS, // can also be HIGH_PRIORITY_CLASS
// or IDLE_PRIORITY_CLASS
NULL, // inherit this process's
// environment block
NULL, // specifies working directory
// of created process
&si, // STA RTUPINFO specified above
&pi // PROCESS_INFORMATION returned
)
)
{
// HANDLE pH = pi.hProcess;
// // wait until application is ready for input
// if ( !WaitForInputIdle( pH,1000 ) )
// {
// // send messages, etc.
// }
// kill process with 0 exit code
// TerminateProcess( pH, 0 );
}
else
{
AfxMessageBox( "Ping.exe 文件当前目录不存在!" );
}

还有第三种办法,API函数
ShellExecute(0, NULL,fullPathFileName, NULL, NULL, SW_RESTORE);
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式