Q:如何開啟內定的瀏覽器及電子郵件程式? A:使用 ShellExecute。該函式定義於 Delphi 的 ShellApi.pas 中: function ShellExecute(hWnd: HWND; Operation, FileName, Parameters, Directory: PChar; ShowCmd: Integer): HINST; stdcall; 參數: hWnd: handle to parent window Operation: pointer to a string that specifies the operation to perform. The valid strings are "open" and "print" to open or print the file specified by "FileName". FileName: pointer to a filename string Parameter: pointer to a string that specifies the executable-file parameters Directory: pointer to a string that specifies the default directory ShowCmd: specifies how the application is to be shown when it is opened 如果 FileName 指定的檔案是一個文件的話,ShowCmd 要設為 0。 開啟電子郵件程式: ShellExecute(handle, 'open', 'Mailto:'', nil, nil, SW_SHOWNORMAL); 開啟瀏覽器: ShellExecute(handle, 'open', 'http://www.mypage.com'', nil, nil, SW_SHOWNORMAL); 以下為加上錯誤處理的函式: procedure ExploreWeb(handle:HWND ;page: PChar); var ReturnValue: integer; begin ReturnValue := ShellExecute(handle, 'open', page, nil, nil, SW_SHOWNORMAL); if ReturnValue <= 32 then case Returnvalue of 0: ShowMessage('Error: Out of Memory'); ERROR_FILE_NOT_FOUND: ShowMessage('Error: File not found'); ERROR_PATH_NOT_FOUND: ShowMessage('Error: Directory not'); ERROR_BAD_FORMAT : ShowMessage('Error: Wrong format in EXE'); // All other errors . See help for more ReturnValues of // ShellExecute else ShowMessage('Error: '+IntToStr(Returnvalue)+' in ShellExecute'); end //case end; 使用範例: ExploreWeb(handle,'http://www.myweb.de/help.htm');