如何在程式中呼叫其它的執行檔 |
|
apple
一般會員 發表:3 回覆:1 積分:0 註冊:2002-04-12 發送簡訊給我 |
|
hagar
版主 發表:143 回覆:4056 積分:4445 註冊:2002-04-14 發送簡訊給我 |
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 發送簡訊給我 |
引言: 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 發送簡訊給我 |
應該是您在執行 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 發送簡訊給我 |
|
daniel710624
一般會員 發表:11 回覆:13 積分:4 註冊:2003-04-11 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |