在寫程序的時(shí)候,有時(shí)我們?yōu)榱耸×Γ蛘邽榱藙e的目的,我們常常想借用系統(tǒng)的對(duì)話框,那么,如何才能調(diào)用系統(tǒng)對(duì)話框呢?一位朋友是VB中是這樣調(diào)用“打開方式”對(duì)話框的: winexec(PChar('rundll32 shell32,OpenAs_RunDLL '+FilePath),SW_SHOWDEFAULT); 這句代碼是運(yùn)行rundll32.exe,讓它調(diào)用shell32.dll中的資源來實(shí)現(xiàn)的。方法可行,但是有許多像我一樣的菜鳥并不明白如何調(diào)用shell32.dll中的寶貴資源,我們應(yīng)該如何去做呢? 下面說說我是如何調(diào)用的: 一、調(diào)用系統(tǒng)“About”對(duì)話框: 首先在uses中加入SHellApi, 然后寫下如下代碼: szOtherStuff [in] Pointer to a null-terminated string containing text that will be displayed in the dialog box after the version and copyright information. hIcon [in] Icon that the function displays in the dialog box. If this parameter is NULL, the function displays the Microsoft® Windows® or Microsoft Windows NT® icon. 什么意思我想不用我來翻譯了吧,這些東西自己去看最好。 二、調(diào)用關(guān)機(jī)對(duì)話框 我們只要把begin部分代碼改為 begin shellapp := CreateOleObject('Shell.application'); shellapp.ShutDownWindows; end; 其他部分不變。運(yùn)行點(diǎn)擊button我們就可以看到標(biāo)準(zhǔn)的系統(tǒng)關(guān)機(jī)對(duì)話框了。 其實(shí)這還是調(diào)用的WindowsAPI函數(shù)shutdownwindows. 這個(gè)部分使用的是windows的shell application的method中的兩個(gè)函數(shù)。method其他的函數(shù)還有: BrowseForFolder、CascadeWindows、ControlPanelItem、EjectPC、Explore、FileRun、FindComputer、FindFiles、Help、MinimizeAll、NameSpace、Open、RefreshMenu、SetTime、TileHorizontally、TileVertically、TrayProperties、UndoMinimizeALL。我也只是學(xué)會(huì)了使用其中的幾個(gè)函數(shù)。詳細(xì)情況請(qǐng)大家查看MSDN中有關(guān)shell object的內(nèi)容。