Windows Programming Note 1: The 2nd Chapter: Win32 Program Operation principle

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.