1. Application entry point
Application Type entry point embedded Executable File startup Function
-------------------------------------------------------------------------------
GUI application winmain winmaincrtstartup that requires ANSI characters and strings
GUI application wwinmain wwinmaincrtstartup that requires Unicode characters and strings
Cui application main maincrtstartup that requires ANSI characters and strings
Cui application wmain wmaincrtstartup that requires Unicode characters and strings
(VC ++) if the/subsystem Sequence Switch is not specified for the linker, the linking program can automatically determine which application should be connected.
Subsystem:
When linking, the linking program needs to check which of the four functions (winmain, wwinmain, main, or wmain) exist in the code.
Then determine which sub-system the executable program should be, and determine which C/C ++ startup function should be embedded in the executable program.
This provides maximum flexibility.
2. Global variables (including stdlib. h) in the C/C ++ runtime that can be used by the program)
Variable name type description
Bytes -------------------------------------------------------------------------------------------
--
_ Test version of the osver unsignedint operating system. For example, windows2000beta3 is a test
Try version 2031. Therefore, the value of _ osver is 2031
_ Winmajor unsignedint is a major Windows version in hexadecimal notation. For Windows
In 2000, the value is 5.
_ Winminor unsignedint is a secondary version of Windows in hexadecimal notation. For Windows
In 2000, the value is 0.
_ Winver unsignedint (_ winmajor <8) + _ winminor parameter number passed on the command line
_ Argc unsignedint
_ Argv char ** an array of _ argc sizes with pointers to ANSI/Unicode strings
_ Wargv wchar_t ** each array item points to a command line parameter
_ Environ char ** refers to an array of pointers to ANSI/Unicode strings. Each array item points
An environment string
_ Wenviron wchar_t **
_ Pgmptr char * Full ANSI/Unicode path and name of the running program
_ Wpgmptrwchar_t *
3. dll Memory base address
Call getmodulehandle and pass the null value to return the base address of the executable file in the process address space. Therefore,
The returned value is the base address of the executable file, not
The base address of the DLL file.
[Note:] You can use the first parameter of the dllmain function to obtain the base address of the DLL file.
3. About CreateProcess
The lpcommandline parameter type of the CreateProcess function is lptstr.
This means that CreateProcess expects you to pass a very large string address. Internally, CreateProcess actually needs to be repaired.
Change to pass
Command Line string. However, before CreateProcess returns, it restores the string to its original form.
This problem is very important, because if the command line string is not included in the read-only part of the file image, there will be access violations (
In some cases, the problem may not occur ).
For example, the following code:
CreateProcess (null, text ("Notepad "),...);
Because VC ++ puts the constant string "Notepad" into the read-only memory by default.
(See the/GF compilation switch of VC)