#include "shellapi.h"
void LoadEXE(LPCTSTR strPath)
{
SHELLEXECUTEINFO sei;
WIN32_FIND_DATA wfd;
HANDLE hFile=NULL;
hFile = FindFirstFile(strPath,&wfd);
if((hFile != INVALID_HANDLE_VALUE) && (hFile !=NULL))
{
FindClose(hFile);
ZeroMemory(&sei, sizeof(SHELLEXECUTEINFO));
sei.cbSize = sizeof(SHELLEXECUTEINFO);
sei.lpFile = strPath ;
sei.nShow = SW_SHOW;
ShellExecuteEx(&sei);
}
return;
}
使用例子
LoadEXE(L"\\System\\powertest.exe");
本文提供了一个使用C++在Windows环境下加载并运行指定路径EXE文件的示例代码。通过SHELLEXECUTEINFO结构体及ShellExecuteEx函数实现。示例展示了如何查找指定路径的文件,并使用Shell API来启动该应用程序。
3058

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



