如何知道 程式是否在Windows 工作管理員?? |
答題得分者是:ko
|
elvis114
一般會員 發表:37 回覆:53 積分:18 註冊:2003-06-17 發送簡訊給我 |
|
ko
資深會員 發表:28 回覆:785 積分:444 註冊:2002-08-14 發送簡訊給我 |
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 發送簡訊給我 |
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 發送簡訊給我 |
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 發送簡訊給我 |
|
ko
資深會員 發表:28 回覆:785 積分:444 註冊:2002-08-14 發送簡訊給我 |
|
elvis114
一般會員 發表:37 回覆:53 積分:18 註冊:2003-06-17 發送簡訊給我 |
|
ko
資深會員 發表:28 回覆:785 積分:444 註冊:2002-08-14 發送簡訊給我 |
|
elvis114
一般會員 發表:37 回覆:53 積分:18 註冊:2003-06-17 發送簡訊給我 |
So , ko :
你可能誤會我的意思了!!
我要的是舉例如下:
if ApplicationUse(('wuauclt.exe') then
begin
KillSelectedProcess_Name('wuauclt.exe');
end;
所以我要如何寫出 KillSelectedProcess_Name Code. 來用 或
我要如何改KillSelectedProcess 變成我想要的東西. =======================
謝謝各位大德不吝賜教!!
小弟感激不進
=======================
------
願 南無藥師琉璃光如來 保佑您 |
ko
資深會員 發表:28 回覆:785 積分:444 註冊:2002-08-14 發送簡訊給我 |
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 我覺得多此一舉....
------
====================== 昏睡~ 不昏睡~ 不由昏睡~ |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |