启动其它程序

1、WinExec

#include <Windows.h>

WinExec("C:\Program Files\MyApp", SW_SHOWNORMAL);

WinExec(""C:\Program Files\MyApp.exe" -L -S", SW_SHOWNORMAL);

2、ShellExecute

#include <shellapi.h>

ShellExecute(NULL, NULL, _T("C:\Program Files\MyApp.exe"), NULL, NULL, SW_SHOWNORMAL);

ShellExecute(NULL, NULL, _T("C:\Program Files"), NULL, NULL, SW_SHOWNORMAL);

ShellExecute(NULL, "open", _T("C:\Program Files"), NULL, NULL, SW_SHOWNORMAL);

ShellExecute(NULL, "explore", _T("C:\Program Files"), NULL, NULL, SW_SHOWNORMAL);

ShellExecute(NULL, "find", _T("C:\Program Files"), NULL, NULL, 0);

3、ShellExecuteEx

#include <shellapi.h>

SHELLEXECUTEINFO ShExecInfo;
ShExecInfo.cbSize = sizeof(ShExecInfo);
ShExecInfo.fMask = NULL;
ShExecInfo.hwnd = NULL;
ShExecInfo.lpVerb = NULL;
ShExecInfo.lpParameters = NULL;
ShExecInfo.lpDirectory = NULL;
ShExecInfo.nShow = SW_SHOWNORMAL;
ShExecInfo.hInstApp = NULL;
ShExecInfo.lpFile = _T("C:\Program Files\MyApp.exe");
ShellExecuteEx(&ShExecInfo);

4、CreateProcess

#include <Windows.h>

STARTUPINFO si;
PROCESS_INFORMATION pi;

ZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);
ZeroMemory(&pi, sizeof(pi));

if (CreateProcess(NULL, _T("C:\Program Files\MyApp.exe"), NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
{
WaitForSingleObject(pi.hProcess, INFINITE);

CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
}

5、CreateProcessAsUser

6、CreateProcessWithLogonW

7、CreateProcessWithTokenW

留下评论

您的邮箱地址不会被公开。 必填项已用 * 标注