程式的入口

2021-08-08 06:34:04 字數 940 閱讀 6032

作業系統裝載應用程式後,做完初始化工作就轉到程式的入口點執行。程式的預設入口點由連線程式設定, 不同的聯結器選擇的入口函式也不盡相同。在vc++下,聯結器對控制台程式設定的入口函式是 maincrtstartup,maincrtstartup 再呼叫main 函式;對圖形使用者介面(gui)程式設定的入口函式是 winmaincrtstartup,winmaincrtstartup 呼叫你自己寫的 winmain 函式。具體設定哪個入口點是由聯結器的「/subsystem:」選項確定的,它告訴作業系統如何執行編譯生成的.exe檔案。可以指定四種方式:console|windows|native|posix。如果這個選項引數的值為 windows,則表示該應用程式執行時不需要控制台,有關聯結器引數選項的詳細說明請參考 msdn 庫。

以下四種組合,可以實現console和windows模式的混合,可以達到不彈出dos視窗的效果,也可以達到在windows程式中向控制台輸出printf資訊的目的。

#pragma comment( linker, "/subsystem:windows /entry:winmaincrtstartup" )

#pragma comment( linker, "/subsystem:windows /entry:maincrtstartup" )

#pragma comment( linker, "/subsystem:console /entry:maincrtstartup" )

#pragma comment( linker, "/subsystem:console /entry:winmaincrtstartup" )

int apientry winmain(hinstance hinstance,

hinstance hprevinstance,

lpstr      lpcmdline,

int        ncmdshow)

int main(void)

程式入口 專題

test 1 26 t 裸函式.exe test 行 90 kernel32.dll 775a337a 未知 ntdll.dll 77c39882 未知 ntdll.dll 77c39855 未知 預設 1 26 t 裸函式.exe wmain int argc,wchar t argv 行 99 ...

Yii web程式入口(3)

來至 yii path base cmodule.php php 第二個引數標識如果是空則建立之,預設為true public function getcomponent id,createifnull true 下面是yii createcomponent的實現 php public static...

關於Android程式入口的猜想

那可以理解說,在啟動應用程式的時候,zygote服務先啟動乙個虛擬機器例項,然後由這個虛擬機器來對應用進行解析。每個android應用都存在androidmanifest.xml檔案,解析這個檔案就會了解整個應用的元件資訊,在其中會指定乙個activity的intent filter內容為 acti...