WINDOWS核心編程之進程(一)

大笑微笑生氣吐舌頭吐舌頭吐舌頭吐舌頭吐舌頭吐舌頭吐舌頭吐舌頭吐舌頭吐舌頭吐舌頭生氣微笑大笑


偷笑我愛北京天安門偷笑


偷笑天安門上太陽升偷笑


偷笑偉大領袖毛主席偷笑


偷笑指引我們向前進偷笑

偷笑大笑大笑大笑大笑大笑大笑大笑大笑大笑大笑大笑大笑大笑大笑大笑大笑偷笑

<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><FONT size=4>2004年7月14日&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 晚20:10</FONT></SPAN></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><FONT size=4>從今天開始說說進程</FONT></SPAN></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><FONT size=4></FONT></SPAN>&nbsp;</P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=4><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">進程通常被定義爲一人正在運行的程序的實例,它由兩個部分組成</SPAN><SPAN lang=EN>:</SPAN></FONT></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 18pt; TEXT-INDENT: -18pt; mso-list: l0 level1 lfo1; tab-stops: list 18.0pt"><FONT color=#ff1493><FONT size=4><SPAN lang=EN style="mso-fareast-font-family: 'Times New Roman'"><SPAN style="mso-list: Ignore">1.<SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN></SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">一個是操作系統用來管理進程的內核對象,內核對象也是系統用來存放關於進程的統計信息的地方。</SPAN></FONT></FONT></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 18pt; TEXT-INDENT: -18pt; mso-list: l0 level1 lfo1; tab-stops: list 18.0pt"><FONT color=#ff1493><FONT size=4><SPAN lang=EN style="mso-fareast-font-family: 'Times New Roman'"><SPAN style="mso-list: Ignore">2.<SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN></SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">另一個是地址空間,它包含所有可執行模塊或</SPAN><SPAN lang=EN>DLL</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">模塊的代碼和數據。它還包含動態內存分配的空間。如線程堆棧和堆分配空間。</SPAN></FONT></FONT></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p><FONT size=4>&nbsp;</FONT></o:p></SPAN></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=4><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">要使進程完成某項操作,它必須要有一個自已的線程,來執行包含在此進程的地址空間中的代碼。每個線程都有它自已的一組</SPAN><SPAN lang=EN>CPU</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">寄存器和它自已的堆棧。</SPAN></FONT></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN><o:p><FONT size=4>&nbsp;</FONT></o:p></SPAN></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=4><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">多個線程是如何運行的呢,操作系統爲每個線程安排一定的</SPAN><SPAN lang=EN>CPU,</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">通過一種循環方式爲線程式提供時間片</SPAN><SPAN lang=EN>(</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">稱爲量稱</SPAN><SPAN lang=EN>)</SPAN></FONT></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN><o:p><FONT size=4>&nbsp;</FONT></o:p></SPAN></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=4><SPAN lang=EN>Windows</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">支持兩種類型的應用程序。一種是基於圖形用戶界面</SPAN><SPAN lang=EN>(GUI)</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的應用程序,另一種是基於控制檯用戶界面</SPAN><SPAN lang=EN>(CUI)</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的應用程序。</SPAN></FONT></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN><o:p><FONT size=4>&nbsp;</FONT></o:p></SPAN></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=4><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">在</SPAN><SPAN lang=EN>vc</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">設置裏的鏈接程序根據</SPAN><SPAN lang=EN> /SUBSYSTEM:CONDOLE</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">還是</SPAN><SPAN lang=EN>/SUBSYSTEM:WINDOWS,</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">當用戶運行一個應用程序時,</SPAN><SPAN lang=EN>os</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的加載程序查看可執行圖形程序的標題,並抓取該子系統的值,如果該值指明一個</SPAN><SPAN lang=EN>CUI</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">應用程序,那麼加載程序就會自動保證爲該應用程序創建文本控制檯窗口。反之加載應用程序,當應用程序啓動運行後,</SPAN><SPAN lang=EN>os</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">就不再關心應用程序擁有什麼類型的用戶界面了。</SPAN></FONT></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN><o:p><FONT size=4>&nbsp;</FONT></o:p></SPAN></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=4><SPAN lang=EN>Windows</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">提供的四個應用程序啓動運行時調用的進入點函數</SPAN></FONT></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN><FONT size=4>Int WINAPI WinMain(HINSTANCE hinstExe, HINSTANCE, PSTR pszCmdLine, int nCmdShow);</FONT></SPAN></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=4><SPAN lang=EN>//</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">第二個參數表示前一個實例句柄</SPAN><SPAN lang=EN>,</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">它是用在</SPAN><SPAN lang=EN>16</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">位</SPAN><SPAN lang=EN>windows</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">上的</SPAN></FONT></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN><FONT size=4>Int WINAPI wWinMain(HINSTANCE hinstExe, HINSTANCE, PWSTR nszCmdLine, int nCmdShow);l</FONT></SPAN></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN><o:p><FONT size=4>&nbsp;</FONT></o:p></SPAN></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN><FONT size=4>Int _cdecl main(int argc, char *agrv[], char *envp[]);</FONT></SPAN></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN><o:p><FONT size=4>&nbsp;</FONT></o:p></SPAN></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN><FONT size=4>Int _cdecl wmain(int argc, wchar_t *argv[], wchar_t *envp[]);</FONT></SPAN></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN><o:p><FONT size=4>&nbsp;</FONT></o:p></SPAN></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=4><FONT color=#ff0000><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">注意:</SPAN><SPAN lang=EN>os</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">並不調用我們編寫的進入點函數,它是調用的是</SPAN><SPAN lang=EN>c/c++</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">運行期啓動函數。該</SPAN> <SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">函數負責對</SPAN><SPAN lang=EN>c/c++</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">運行期庫進行初始化</SPAN><SPAN lang=EN>, </SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">這樣,就可以調用</SPAN><SPAN lang=EN>malloc</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">和</SPAN><SPAN lang=EN>free</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">之類的函數。它還能確保已經聲名的任何全局對象和靜態</SPAN><SPAN lang=EN>c++</SPAN></FONT><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><FONT color=#ff0000>對象能夠在代碼執行之前正確的創建</FONT>。</SPAN></FONT></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN><o:p><FONT size=4>&nbsp;</FONT></o:p></SPAN></P><SPAN lang=EN><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 178.5pt; mso-char-indent-count: 17.0"><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">應用程序的進入點</SPAN></P></SPAN><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN><o:p>&nbsp;應用程序類型&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;進入點&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;嵌入可執行文件的啓動函數</o:p></SPAN></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN><o:p>需要ASCI字符和字符串的GUI應用程序&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;WinMain&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;WinMainCRTStartup</o:p></SPAN></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN><o:p>需要UNICODE字符和字符串的GUI應用程序&nbsp;&nbsp;wWinMain&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;wWinMainCRTStartup</o:p></SPAN></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN><o:p><SPAN lang=EN><o:p>需要ASCI字符和字符串的CUI應用程序&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;main&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mainCRTStartup</o:p></SPAN></o:p></SPAN></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN><o:p><SPAN lang=EN><o:p><SPAN lang=EN><o:p>需要UNICODE字符和字符串的CUI應用程序&nbsp;wmain&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;wmainCRTStartup</o:p></SPAN></o:p></SPAN></o:p></SPAN></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN><o:p><SPAN lang=EN><o:p><SPAN lang=EN><o:p></o:p></SPAN></o:p></SPAN></o:p></SPAN><FONT size=4>&nbsp;</FONT></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=4><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">所有的</SPAN><SPAN lang=EN>c/c++</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">運行期啓動函數的作用都是相同的,只不過處理</SPAN><SPAN lang=EN>ANSI</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">字符串還是</SPAN><SPAN lang=EN>Unicode</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">字符串,以及它們在對</SPAN><SPAN lang=EN>C</SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">運行期庫進行初始化後它們調用哪個進入點函數。</SPAN></FONT></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><FONT size=4></FONT></SPAN>&nbsp;</P><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=4><SPAN lang=EN><FONT face="Times New Roman">C</FONT></SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">運行期庫的源代碼在</SPAN><SPAN lang=EN><FONT face="Times New Roman">CRt0.c</FONT></SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">文件裏</SPAN></FONT></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=4><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">其主要功能如下</SPAN><SPAN lang=EN><FONT face="Times New Roman">:</FONT></SPAN></FONT></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 18pt; TEXT-INDENT: -18pt; mso-list: l0 level1 lfo1; tab-stops: list 18.0pt"><FONT color=#ff1493><FONT size=4><SPAN lang=EN style="mso-fareast-font-family: 'Times New Roman'"><SPAN style="mso-list: Ignore"><FONT face="Times New Roman">1.<SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></FONT></SPAN></SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">檢索指向新進程的完整命令行的指針</SPAN><SPAN lang=EN><FONT face="Times New Roman">.</FONT></SPAN></FONT></FONT></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 18pt; TEXT-INDENT: -18pt; mso-list: l0 level1 lfo1; tab-stops: list 18.0pt"><FONT color=#ff1493><FONT size=4><SPAN lang=EN style="mso-fareast-font-family: 'Times New Roman'"><SPAN style="mso-list: Ignore"><FONT face="Times New Roman">2.<SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></FONT></SPAN></SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">檢索指向新進程的環境變量的指針。</SPAN></FONT></FONT></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 18pt; TEXT-INDENT: -18pt; mso-list: l0 level1 lfo1; tab-stops: list 18.0pt"><FONT color=#ff1493><FONT size=4><SPAN lang=EN style="mso-fareast-font-family: 'Times New Roman'"><SPAN style="mso-list: Ignore"><FONT face="Times New Roman">3.<SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></FONT></SPAN></SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">對</SPAN><SPAN lang=EN><FONT face="Times New Roman">c/c++</FONT></SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">運行期的全局變量進行初始化。如果包含了</SPAN><SPAN lang=EN><FONT face="Times New Roman">StdLib.h</FONT></SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">文件,代碼就能訪問這些變量了</SPAN><SPAN lang=EN><FONT face="Times New Roman">(WinMain</FONT></SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">等那四個函數</SPAN><SPAN lang=EN><FONT face="Times New Roman">)</FONT></SPAN></FONT></FONT></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 18pt; TEXT-INDENT: -18pt; mso-list: l0 level1 lfo1; tab-stops: list 18.0pt"><FONT color=#ff1493><FONT size=4><SPAN lang=EN style="mso-fareast-font-family: 'Times New Roman'"><SPAN style="mso-list: Ignore"><FONT face="Times New Roman">4.<SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></FONT></SPAN></SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">對</SPAN><SPAN lang=EN><FONT face="Times New Roman">C</FONT></SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">運行期內存單元分配函數</SPAN><SPAN lang=EN><FONT face="Times New Roman">(malloc</FONT></SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">和</SPAN><SPAN lang=EN><FONT face="Times New Roman">calloc)</FONT></SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">和其它低層輸入</SPAN><SPAN lang=EN><FONT face="Times New Roman">/</FONT></SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">輸出例程使用的內存棧進行初始化。</SPAN></FONT></FONT></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 18pt; TEXT-INDENT: -18pt; mso-list: l0 level1 lfo1; tab-stops: list 18.0pt"><FONT color=#ff1493><FONT size=4><SPAN lang=EN style="mso-fareast-font-family: 'Times New Roman'"><SPAN style="mso-list: Ignore"><FONT face="Times New Roman">5.<SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></FONT></SPAN></SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">爲所有全局和靜態</SPAN><SPAN lang=EN><FONT face="Times New Roman">c++</FONT></SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">類對象調用構造函數。</SPAN></FONT></FONT></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=4><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">完成以上的功能後,</SPAN><SPAN lang=EN><FONT face="Times New Roman">c/c++</FONT></SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">啓動函數就調用應用程序的進入點函數。</SPAN></FONT></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN><o:p><FONT face="Times New Roman" size=4>&nbsp;</FONT></o:p></SPAN></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=4><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">進入函數返回時</SPAN><SPAN lang=EN><FONT face="Times New Roman">,</FONT></SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">啓動函數便調用</SPAN><SPAN lang=EN><FONT face="Times New Roman">c</FONT></SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">運行期的</SPAN><SPAN lang=EN><FONT face="Times New Roman">exit</FONT></SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">函數,</SPAN><SPAN lang=EN><FONT face="Times New Roman">exit</FONT></SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">函數負責如下的操作</SPAN></FONT></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 18pt; TEXT-INDENT: -18pt; mso-list: l1 level1 lfo2; tab-stops: list 18.0pt"><FONT color=#ff1493><FONT size=4><SPAN lang=EN style="mso-fareast-font-family: 'Times New Roman'"><SPAN style="mso-list: Ignore"><FONT face="Times New Roman">1.<SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></FONT></SPAN></SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">調用由</SPAN><SPAN lang=EN><FONT face="Times New Roman">_onexit</FONT></SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">函數的調用而註冊的任何函數</SPAN></FONT></FONT></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 18pt; TEXT-INDENT: -18pt; mso-list: l1 level1 lfo2; tab-stops: list 18.0pt"><FONT color=#ff1493><FONT size=4><SPAN lang=EN style="mso-fareast-font-family: 'Times New Roman'"><SPAN style="mso-list: Ignore"><FONT face="Times New Roman">2.<SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></FONT></SPAN></SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">爲所有全局的和靜態的</SPAN><SPAN lang=EN><FONT face="Times New Roman">c++</FONT></SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">類對象調用析構函數。</SPAN></FONT></FONT></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 18pt; TEXT-INDENT: -18pt; mso-list: l1 level1 lfo2; tab-stops: list 18.0pt"><FONT color=#ff1493><FONT size=4><SPAN lang=EN style="mso-fareast-font-family: 'Times New Roman'"><SPAN style="mso-list: Ignore"><FONT face="Times New Roman">3.<SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></FONT></SPAN></SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">調用</SPAN><SPAN lang=EN><FONT face="Times New Roman">OS</FONT></SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的</SPAN><SPAN lang=EN><FONT face="Times New Roman">ExitProcess</FONT></SPAN><SPAN style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">函數</SPAN><SPAN lang=EN><FONT face="Times New Roman">.</FONT></SPAN></FONT></FONT></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=4></FONT>&nbsp;</P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=4>待續.............</FONT></SPAN></P>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章