線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:1843
推到 Plurk!
推到 Facebook!

如何在程式中呼叫其它的執行檔

 
apple
一般會員


發表:3
回覆:1
積分:0
註冊:2002-04-12

發送簡訊給我
#1 引用回覆 回覆 發表時間:2002-04-28 00:02:02 IP:61.70.xxx.xxx 未訂閱
請問,如何在程式中呼叫其它的執行檔,並傳參數給該執行檔, 所傳入的參數,在程式中要如何接收? 謝謝!
hagar
版主


發表:143
回覆:4056
積分:4445
註冊:2002-04-14

發送簡訊給我
#2 引用回覆 回覆 發表時間:2002-04-28 17:18:07 IP:211.22.xxx.xxx 未訂閱
1.用 ShellExecute 呼叫其它執行檔, 例(呼叫 xxx.exe, 其傳入參數 1 2 3: uses ShellApi; ShellExecute(0, PChar('open'), PChar('xxx.exe 1 2 3'), nil, nil, SW_SHOW); 2.在程式中接收參數, 例: procedure TForm1.FormCreate(Sender: TObject); var i: Integer; for i := 0 to ParamCount-1 do begin if ParamStr(i) = '1' then showmessage('參數為 1') else if ParamStr(i) = '2' then showmessage('參數為 2') else if ParamStr(i) = '3' then showmessage('參數為 3'); end; end;
BettyChang
一般會員


發表:1
回覆:3
積分:0
註冊:2002-09-13

發送簡訊給我
#3 引用回覆 回覆 發表時間:2002-10-23 11:44:31 IP:61.30.xxx.xxx 未訂閱
引言: 1.用 ShellExecute 呼叫其它執行檔, 例(呼叫 xxx.exe, 其傳入參數 1 2 3: uses ShellApi; ShellExecute(0, PChar('open'), PChar('xxx.exe 1 2 3'), nil, nil, SW_SHOW); 2.在程式中接收參數, 例: procedure TForm1.FormCreate(Sender: TObject); var i: Integer; for i := 0 to ParamCount-1 do begin if ParamStr(i) = '1' then showmessage('參數為 1') else if ParamStr(i) = '2' then showmessage('參數為 2') else if ParamStr(i) = '3' then showmessage('參數為 3'); end; end;
版主: 我在Delphi 7 中用ShellExecute 呼叫其它執行檔,可是都沒有反應 這是怎麼一回事?? ........Help!!
hagar
版主


發表:143
回覆:4056
積分:4445
註冊:2002-04-14

發送簡訊給我
#4 引用回覆 回覆 發表時間:2002-10-23 14:57:51 IP:202.39.xxx.xxx 未訂閱
應該是您在執行 ShellExecute 時, 沒有指定 xxx.exe 的完整路徑。 其它可檢查 ShellExecute 的回傳值, 以判斷是什麼問題, 其可能值如下(截自 Help): Value        Meaning 0: The operating system is out of memory or resources. ERROR_FILE_NOT_FOUND: The specified file was not found. ERROR_PATH_NOT_FOUND: The specified path was not found. ERROR_BAD_FORMAT: The .EXE file is invalid (non-Win32 .EXE or error in .EXE image). SE_ERR_ACCESSDENIED: The operating system denied access to the specified file.  SE_ERR_ASSOCINCOMPLETE: The filename association is incomplete or invalid. SE_ERR_DDEBUSY: The DDE transaction could not be completed because other DDE transactions were being processed. SE_ERR_DDEFAIL: The DDE transaction failed. SE_ERR_DDETIMEOUT: The DDE transaction could not be completed because the request timed out. SE_ERR_DLLNOTFOUND: The specified dynamic-link library was not found.  SE_ERR_FNF: The specified file was not found.  SE_ERR_NOASSOC: There is no application associated with the given filename extension. SE_ERR_OOM: There was not enough memory to complete the operation. SE_ERR_PNF: The specified path was not found. SE_ERR_SHARE: A sharing violation occurred.    -- Everything I say is a lie. 發表人 - hagar 於 2002/10/23 15:23:38
morin
一般會員


發表:1
回覆:2
積分:0
註冊:2003-01-24

發送簡訊給我
#5 引用回覆 回覆 發表時間:2003-04-07 14:06:19 IP:61.13.xxx.xxx 未訂閱
ShellExecute(0, PChar('open'), PChar('xxx.exe'),('1 2 3'), nil, SW_SHOW);
daniel710624
一般會員


發表:11
回覆:13
積分:4
註冊:2003-04-11

發送簡訊給我
#6 引用回覆 回覆 發表時間:2003-04-15 13:37:34 IP:210.201.xxx.xxx 未訂閱
感謝您!我試過了,沒問題耶!不過您提到 ShellExecute(0, PChar('open'), PChar('xxx.exe 1 2 3'), nil, nil, SW_SHOW); 我在第二個參數直接用'open'好像也可以....請教有Pchar跟沒有是否有 差別或任何影響嗎?
系統時間:2024-06-18 22:05:43
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!