全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:2168
推到 Plurk!
推到 Facebook!

如何知道 程式是否在Windows 工作管理員??

答題得分者是:ko
elvis114
一般會員


發表:37
回覆:53
積分:18
註冊:2003-06-17

發送簡訊給我
#1 引用回覆 回覆 發表時間:2003-07-17 11:54:05 IP:61.220.xxx.xxx 未訂閱
如何知道程式是否在Windows 工作管理員中的處理程序, 如果知道後要如何Kill此程式呢?? 請教個位高手!!
------

南無藥師琉璃光如來
保佑您
ko
資深會員


發表:28
回覆:785
積分:444
註冊:2002-08-14

發送簡訊給我
#2 引用回覆 回覆 發表時間:2003-07-17 17:54:31 IP:61.221.xxx.xxx 未訂閱
elvis114你好: 因為時間衝忙有問題明天回 function ApplicationUse(fName : string) : boolean; var hSS: THandle; ProcEntry32: PROCESSENTRY32; iCount: Integer; begin Result := False; iCount := 0; hSS := CreateToolHelp32Snapshot(TH32CS_SNAPALL, 0); ProcEntry32.dwSize := sizeof(ProcEntry32); //----------------- if Process32First(hSS, ProcEntry32) then begin repeat // Application.MessageBox((ProcEntry32.szExeFile),'...'); if UpperCase(ProcEntry32.szExeFile) = UpperCase(fName) then begin spid := ProcEntry32.th32ProcessID; Inc(iCount); if iCount >= 1 then begin Result := True; Break; end; end; until not Process32Next(hSS, ProcEntry32); CloseHandle(hSS); end; //-------------- if Result then Exit; end; function KillSelectedProcess(PID:integer):String; var lpExitCode : DWord; hProcess : Cardinal; begin hProcess := Int64(PID); PH := OpenProcess(PROCESS_TERMINATE or PROCESS_QUERY_INFORMATION,FALSE, hProcess); if PH <> 0 then begin if GetExitCodeProcess(PH, lpExitCode) then TerminateProcess(PH, lpExitCode) else Result := 'Could not retreive the ExitCode for this process.'; CloseHandle(PH); end else Result := 'Could not get access to this process.' end;
------
======================
昏睡~
不昏睡~
不由昏睡~
elvis114
一般會員


發表:37
回覆:53
積分:18
註冊:2003-06-17

發送簡訊給我
#3 引用回覆 回覆 發表時間:2003-07-18 08:49:10 IP:61.220.xxx.xxx 未訂閱
Dear Ko :        我在compile 時候會出現以下Error,是否還要Uses 那些物件呢??    [Error] Utility.pas(77): Undeclared identifier: 'PROCESSENTRY32' [Error] Utility.pas(82): Undeclared identifier: 'CreateToolHelp32Snapshot' [Error] Utility.pas(82): Undeclared identifier: 'TH32CS_SNAPALL' [Error] Utility.pas(83): Missing operator or semicolon [Error] Utility.pas(85): Undeclared identifier: 'Process32First' [Error] Utility.pas(89): ')' expected but identifier 'szExeFile' found [Error] Utility.pas(91): Undeclared identifier: 'spid' [Error] Utility.pas(91): Missing operator or semicolon [Error] Utility.pas(100): Undeclared identifier: 'Process32Next' [Error] Utility.pas(113): Undeclared identifier: 'PH' [Warning] Utility.pas(114): Comparing signed and unsigned types - widened both operands [Fatal Error] Utility.pas(4): Could not compile used unit 'Utility'    ======================= 謝謝各位大德不吝賜教!! 小弟感激不進 =======================
------

南無藥師琉璃光如來
保佑您
ko
資深會員


發表:28
回覆:785
積分:444
註冊:2002-08-14

發送簡訊給我
#4 引用回覆 回覆 發表時間:2003-07-18 19:24:29 IP:61.221.xxx.xxx 未訂閱
elvis114你好: 要 uses TlHelp32; 還有在 var   Form1: TForm1;   spid:Integer; PH : THandle; implementation 加上紅色的宣告 然後 if ApplicationUse(ap) then begin KillSelectedProcess(spid); end; 當然ap你要殺的程式名稱,如 wuauclt.exe <--M$的更新程式
------
======================
昏睡~
不昏睡~
不由昏睡~
elvis114
一般會員


發表:37
回覆:53
積分:18
註冊:2003-06-17

發送簡訊給我
#5 引用回覆 回覆 發表時間:2003-07-21 10:29:31 IP:61.220.xxx.xxx 未訂閱
謝謝KO!! 但是如果要Kill '影像名稱'; 如何做呢?? 再麻煩你了!!    ======================= 謝謝各位大德不吝賜教!! 小弟感激不進 =======================
------

南無藥師琉璃光如來
保佑您
ko
資深會員


發表:28
回覆:785
積分:444
註冊:2002-08-14

發送簡訊給我
#6 引用回覆 回覆 發表時間:2003-07-22 13:52:42 IP:61.221.xxx.xxx 未訂閱
elvis114你好:    sorry,不知所云... 
引言: ....'影像名稱';
DC是嗎
------
======================
昏睡~
不昏睡~
不由昏睡~
elvis114
一般會員


發表:37
回覆:53
積分:18
註冊:2003-06-17

發送簡訊給我
#7 引用回覆 回覆 發表時間:2003-07-22 16:37:24 IP:61.220.xxx.xxx 未訂閱
Dear Ko : Sorry 沒有寫清楚,應該是Kill ap名稱, 如何做呢?? 再麻煩你了!! ======================= 謝謝各位大德不吝賜教!! 小弟感激不進 =======================
------

南無藥師琉璃光如來
保佑您
ko
資深會員


發表:28
回覆:785
積分:444
註冊:2002-08-14

發送簡訊給我
#8 引用回覆 回覆 發表時間:2003-07-22 17:21:24 IP:61.221.xxx.xxx 未訂閱
引言: if ApplicationUse('wuauclt.exe') then begin KillSelectedProcess(spid); end;
------
======================
昏睡~
不昏睡~
不由昏睡~
elvis114
一般會員


發表:37
回覆:53
積分:18
註冊:2003-06-17

發送簡訊給我
#9 引用回覆 回覆 發表時間:2003-07-23 07:51:52 IP:61.220.xxx.xxx 未訂閱
So , ko : 你可能誤會我的意思了!! 我要的是舉例如下: if ApplicationUse(('wuauclt.exe') then begin KillSelectedProcess_Name('wuauclt.exe'); end; 所以我要如何寫出 KillSelectedProcess_Name Code. 來用 或 我要如何改KillSelectedProcess 變成我想要的東西. ======================= 謝謝各位大德不吝賜教!! 小弟感激不進 =======================
------

南無藥師琉璃光如來
保佑您
ko
資深會員


發表:28
回覆:785
積分:444
註冊:2002-08-14

發送簡訊給我
#10 引用回覆 回覆 發表時間:2003-07-23 18:29:31 IP:61.221.xxx.xxx 未訂閱
elvis114你好:  
引言: if ApplicationUse('wuauclt.exe') then begin KillSelectedProcess(spid); end;
引言: function ApplicationUse(fName : string) : boolean; var ... ..... ...... if UpperCase(ProcEntry32.szExeFile) = UpperCase(fName) then begin //function 中很清楚的將fName就是您尋找的程式名稱得Process值給spid spid := ProcEntry32.th32ProcessID;
因此在下面function 就是把Process刪除就是結束處理程序...
引言:function KillSelectedProcess(PID:integer):String; var ... .... .....
至於要把它縮減成一個function 我覺得多此一舉....
------
======================
昏睡~
不昏睡~
不由昏睡~
系統時間:2024-05-02 21:53:17
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!