-
Notifications
You must be signed in to change notification settings - Fork 0
/
windows-process_1.cpp
63 lines (54 loc) · 1.29 KB
/
windows-process_1.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include <Windows.h>
#include <iostream>
#include <tchar.h>
#include <atlstr.h>
//新建进程
//1:
//int system(const char* command);
//2:
//UINT WinExec(
// LPCSTR lpCmdLine, // command line
// UINT uCmdShow // window style
//);
//3:
//HINSTANCE ShellExecute(
// HWND hwnd,
// LPCTSTR lpVerb,
// LPCTSTR lpFile,
// LPCTSTR lpParameters,
// LPCTSTR lpDirectory,
// INT nShowCmd
//);
//4:
//BOOL CreateProcess
//(
// LPCTSTR lpApplicationName, // 可执行程序名
// LPTSTR lpCommandLine, //[可执行程序名]程序参数
// LPSECURITY_ATTRIBUTES lpProcessAttributes,
// LPSECURITY_ATTRIBUTES lpThreadAttributes,
// BOOL bInheritHandles,
// DWORD dwCreationFlags, //创建标志
// LPVOID lpEnvironment,
// LPCTSTR lpCurrentDirectory,
// LPSTARTUPINFO lpStartupInfo,
// LPPROCESS_INFORMATION lpProcessInformation
//);
//结束进程
//1:
//VOID ExitProcess(UINT uExitCode);
//2:
//TerminateProcess(
// HANDLE hProcess,
// UINT uExitCode);
int main()
{
//system("D:\\Snake.exe");
//WinExec("D:\\Snake.exe", SW_SHOWMAXIMIZED);
//ShellExecute(NULL, "open", "D:\\Snake.exe", NULL, NULL, SW_SHOWNORMAL);
CString str = _T("D:\\Snake.exe");
LPWSTR commandLine = str.GetBuffer();
PROCESS_INFORMATION pi;
STARTUPINFO si = { sizeof(si) };
CreateProcess(commandLine, NULL, NULL, NULL, FALSE, NULL, NULL, NULL, &si, &pi);
return 0;
}