Everyone wants to fly in the field of program design, but don't even think about it before learning.
The essence of the Windows program is Message Based, Event Driven.
Message structure:
/ * Queued message structure * / typedef struct tagMSG {HWND hwnd; UINT message; // WM_XXX WPARAM wParam; LPARAM lParam; DWORD time; POINT pt;} MSG; message map defines a first configuration and dim MSGMAP_ENTRIES macro struct MSGMAP_ENTRIES {UINT nMessage Long (* pfn) (hwnd, uint, wparam, lparam);}; # define Dim (x) (x [x) / sizeof (x [0])) Next, define two arrays _MessageEntries [] and _Commandentries [], establishes the association of the message set message processing constant to be processed in the program.
// the constant message processing table struct MSGMAP_ENTRY -messageEntries [] = {WM_CRATE, OnCreate, WM_PAINT, OnPaint, WM_SIZE, OnSize, WM_COMMAND, OnCommand, WM_SETFOCUS, OnSetFocus, WM_CLOSE, OnClose, WM_DESTROY, OnDestroy,}; struct MSG_ENTRY _commandEntries [] = {IDM_ABOUT, ONWABOUT, IDM_FILEOPEN, ONFILEOPEN, IDM_SAVRAS, ONSAVEAS,}; therefore, window functions can be designed: LRESULT CALLBACK WNDPROC (HWND HWND, UINT Message, WPARAM WPARAM, LPARAM LPARAM) {Int i; for (i = 0; i CreateProcess CreateProcess (LPCSTR lpApplicationName, // application name LPSTR lpCommandLine, // command-line arguments passed to the process LPSECURITY_ATTRIBUTES lpProcessAttributes, // setting process security attributes LPSECURITY_ATTRIBUTES lpThreadAttributes, // thread security attributes BOOL bInheritHandles, // set of security attributes Do you want to be inherited DWORD dwCreationFlags, // a variety of constant collection LPVOID lpEnvironment, // specify LPCSTR lpCurrentDirectory environment variable region, // working directory lPSTARTUPINFO lpStartupInfo, // LPPROCESS_INFORMATION lpProcessInfomation) If a reference to the program name is specified, but does not specify an extension The system will not take the initiative to add the .exe extension. If you do not specify a full path, the system is looking for in the current directory. If you set LPApplicationName to null, the system will use the name of the application of LPCommandline as the name of the application. If no extension is specified, the extension is used to extension. If there is no specified path, Windows finds the application in five looking forward, namely: 1, the caller application is located, the caller is currently working directory 3, windows directory 4, windows system directory 5, environment variables in the environment variable Before setting up a new process, the system must make two core objects, that is, the "Process Object] and [Thread Object] CREATEPROCESS, the third parameter and the fourth parameter specify the security properties of the two core objects, respectively. Typedef struct PROCESS_INFORMATION {HANDLE hProcess; HANDLE hThread; DWORD dwProcessId; DWORD dwThreadId;} PROCESS_INFORMATION; VOID ExitProcess (UINT fuExitCode); // process to end their lives BOOL TerminateProcess (HANDLE hProcess, UINT fuExitCode); // end of the process to another process s life. A thread generation and death 1, configure thread objects, its handle will become the return value of CreateThread. 2, set the count value of 1.3, configure the context4 of the thread, keep the thread's stack 5, and set the stack pointer (SS) and the instruction pointer register (IP) in Context. The so-called work switch is actually a switching of threads. CreateTHREAD (LPSecurity_Attributes LPthReadttributes, // Security Properties settings and inherited DWORD DWSTACKSIZE, // Setting the size of the stack lpthread_start_routine lpstartaddress, // Set the thread function name.