程式要如何執行 dos 下的指令( 例如:arp -s 157.55.85.212 00-aa-00-62-c6-09 ) |
答題得分者是:pceyes
|
salo0610
高階會員 發表:42 回覆:120 積分:107 註冊:2003-02-18 發送簡訊給我 |
|
salo0610
高階會員 發表:42 回覆:120 積分:107 註冊:2003-02-18 發送簡訊給我 |
各位大大你們好:
WinExec( "command.com /c arp -d 157.55.85.212" , SW_HIDE); WinExec( "command.com /c arp -s 157.55.85.212 00-aa-00-62-c6-09" , SW_HIDE); WinExec( "command.com /c arp -d 157.55.85.212" , SW_HIDE); 我用 call dos 的指令完成了, 但是否還有其它方法?? ===================引 用 salo0610 文 章=================== 各位大大你們好: 我想完成如下的功能:(例如) arp -s 157.55.85.212 00-aa-00-62-c6-09 程式用完後: arp -d 157.55.85.212 我的應用程式要如何寫,才能達到以上的功能?? 除了 call dos 指令,是否有其它的方法?? 謝謝!! |
pceyes
尊榮會員 發表:70 回覆:657 積分:1140 註冊:2003-03-13 發送簡訊給我 |
[code delphi]
procedure TForm1.Button1Click(Sender: TObject); var tSI : TStartupInfo; tPI : TProcessInformation; dwI : DWORD; (* WaitForSingleobject Result *) begin FillChar(tSI, sizeof(TStartupInfo), 0); tSI.cb := sizeof(TStartupInfo); tSI.dwFlags := STARTF_USESHOWWINDOW; tSI.wShowWindow:=SW_normal; try if CreateProcess(nil,PChar(edit1.text),nil,nil,true,DETACHED_PROCESS, nil,nil,tSI,tPI) then begin dwI := WaitForSingleObject(tPI.hProcess, 200000); if (dwI <> WAIT_FAILED) then begin if (GetExitCodeProcess(tPI.hProcess, dwI)) then begin if dwI <> STILL_ACTIVE then begin showmessage(edit1.text ' Closed Do Next Process'); end; end; end; end else begin showmessage(edit1.text ' CreatePress Fail'); end; finally CloseHandle(tPI.hProcess); CloseHandle(tPI.hThread); end; end;[/code]
------
努力會更接近成功 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |