📄 launch2.cpp
字号:
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <process.h>
int main(void) {
STARTUPINFO si;
PROCESS_INFORMATION pi;
// fill out the STARTUPINFO structure with default values...
ZeroMemory( &si, sizeof(si));
si.cb = sizeof(si);
// start notepad...
CreateProcess( NULL, "notepad.exe", NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
// print some information...
printf( "Notepad created as process id 0x%08x and thread id 0x%08x.\n",
pi.dwProcessId, pi.dwThreadId);
// this will wait for five seconds...
Sleep(5000);
// forcibly terminate the notepad...
TerminateProcess( pi.hProcess, 0x00000007);
// get notepad's exit code...
DWORD dwNotepadExitCode;
if (GetExitCodeProcess( pi.hProcess, &dwNotepadExitCode))
printf( "Notepad's exit code is 0x%08x.\n", dwNotepadExitCode);
else
printf( "Unable to get notepad's exit code.\n");
// close the newly created process and thread handles...
// this process's handles to notepad's process and thread...
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -