圖4
2.下面我們就來導入windows api函數庫shell32.dll中的shellexecute函數。欲導入windows api函數庫中封裝的函數,我們必須知道這些函數的具體類型聲明(可以參考微軟的msdn中api部分內容),例如shellexecute函數在vb中的函數類型聲明如下:
declare function shellexecute lib "shell32.dll" alias "shellexecutea" (byval hwnd as long, byval lpoperation as string, byval lpfile as string, byval lpparameters as string, byval lpdirectory as string, byval nshowcmd as long) as long
從類型聲明中我們可以知道shellexecute函數的原型是shellexecutea,其參數類型按順序依次為long,string,string,string,string,long,函數返回類型為long。因此我們在圖4所示對話框的【function name】域中填入函數名shellexecutea,【arguments】域中填入參數聲明類型long,string,string,string,string,long,【return】域中填入函數返回類型long,然后單擊按鈕【load】,成功導入函數后,在對話框的左下角有一提示文字:successfully loadded "shellexecutea",如圖5所示。最后單擊按鈕【done】返回authorware設計窗口或者繼續導入其它的api函數。
圖5
3. 導入api函數后就可以直接在程序中使用了,例如在計算圖標里執行以下代碼可以自動打開系統默認的郵件發送程序:
shellexecutea(windowhandle, "open","mailto:hellrock@163.net","","",5)
新聞熱點
疑難解答