The 2nd Chapter: Win32 Program Operation principle
Kernel objects: Object handles, identifiers, process related, can only be accessed by other threads within 1 processes , opaque, encapsulated.
Create process: Returns a Variable object of type Startupinfo that contains the display information passed by the parent process to the child process .
Startupinfo is a class type that is the same as the included type,
Startupinfo si={sizeof (&si)}; Initialize the size of the Startupinfo:: Getstartupinfo (&SI); Calling the Startupinfo object
Create process:CreateProcess () function , function contains a lot of arguments
For example, open Notepad
1Startupinfo si={sizeof(&si)};//new process size, position, Startupinfo type2 3Process_information Pi;//handle of the new process, ID number, Process_info type4 5 Char* szcommandline="Notepad";6 7:: CreateProcess (NULL,Szcommandline,Null,null,false,null,null,null,&si,&pi);
Hungarian notation of the type, prefix notation
b BOOL
Sz string Zero (string ending with 0)
LP long pointer (long pointer)
WINDEF.h contains the macro name corresponding to the variable type
DWORD unsigned long integer unsigned long intWORD unsigned short unsigned-intbool integer intint integral type Intbyte unsigned character type unsigned char constant character pointer const char*lpvoid null pointer void far
Process Control:
0: Get system process: toolhelp () function
The createtoolhelp32snapshot () function Gets the list of process snapshots currently running on the system
Process32First () and Process32Next () traverse the snapshot list
1. Terminate the current process: 1) A thread in the current process called the exitprocess () function
2) Other threads in the process call the terminateprocess () function
3) The threads in the current process are finished running
2. Terminate other processes:terminateprocess () function
3: Protection process: Prevent the current process from being closed
Hook it off . Detection and termination of the current process
Detection: Toolhelp () function,
Termination: TerminateProcess () function
Windows Programming Note 1: The 2nd Chapter: Win32 Program Operation principle