이 프로그램은 시스템 의이 프로세스를 제외한 모든 프로세스의 ID, 해당 파일 지정자, 우선 순위, CPU 공유, 스레드 수, 관련 프로세스 정보 등을 검색하고 나열합니다 선택된 프로세스.
이 프로그램이 실행되면 시스템 트레이 영역에 아이콘이 추가되면 CTRL+Alt+DEL을 누를 때 나타나는 작업 목록에 표시되지 않으며 작업 표시 줄에 작업 버튼이 표시되지 않으면됩니다. 비활성 또는 최소화 될 때 자동으로 숨겨져 있습니다. 프로그램이 이미 실행중인 경우 반복적으로 실행되지 않습니다.
이 프로그램은 반복적 인 프로그램 방법을 피하는 것이 매우 독특합니다. 인터넷에서 몇 가지 방법을 시도한 후, 프로그램이 최소화 된 상태에서 활성화되면 창을 클릭하면 창을 최소화 할 수 없다는 것을 알았습니다. 따라서 저자는 사용자 정의 메시지를 보내고 처리하는 방법을 채택합니다. 프로그램이 실행될 때 먼저 시스템의 Windows를 열거하면 프로그램이 실행중인 경우 프로그램 창에 사용자 정의 메시지를 보내십시오. 실행 프로그램은 사용자 정의 메시지를받은 후 창이 표시됩니다.
// 프로젝트 파일 ProcViewPro.dpr
프로그램 ProcViewPro;
용도
양식, 창, 메시지, 'procview.pas'{form1}의 메인;
{$ r *.res}
{
// 이것은 시스템에 의해 자동입니다
시작하다
application.initialize;
Application.title : = '시스템 프로세스 모니터링';
application.createform (tform1, form1);
application.run;
끝.
}
var
myhwnd : hwnd;
시작하다
myhwnd : = findwindow (nil, '시스템 프로세스 모니터링');
myhwnd = 0이면 // 찾을 수 없으면 계속 실행하십시오
시작하다
application.initialize;
Application.title : = '시스템 프로세스 모니터링';
application.createform (tform1, form1);
application.run;
끝
else // 창을 발견하고 마우스를 보내기 창을 활성화하려면 시스템 트레이 영역 메시지를 클릭하십시오.
postmessage (myhwnd, wm_systraymsg, 0, wm_lbuttondown);
{
// 다음 방법의 단점은 다음과 같습니다. 창이 원래 최소화 된 상태에 있으면 창을 클릭하면 활성화 후 창문을 최소화하면 창이 최소화되지 않습니다.
Showwindow (Myhwnd, Sw_restore);
FlashWindow (MyHwnd, True);
}
끝.
{
// 다음은 반복적 인 프로그램 실행을 피하기 위해 글로벌 원자를 사용하는 방법입니다.
Const
atomstr = 'procview';
var
원자 : 정수;
시작하다
GlobalFindatom (atomstr) = 0 인 경우
시작하다
원자 : = GlobalAddatom (atomstr);
응용 프로그램과 함께
시작하다
초기화;
제목 : = '시스템 프로세스 모니터링';
createform (tform1, form1);
달리다;
끝;
Globaldetleateatom (원자);
끝;
끝.
}
// 단위 파일 ProcView.pas
단위 ProcView;
인터페이스
용도
창, 메시지, 시스템, 클래스, 그래픽, 컨트롤, 양식, 대화, 대화,
stdctrls, tlhelp32, 버튼, comctrls, extctrls, shellapi, myflag;
Const
process_terminate = 0;
systray_id = 1;
WM_SYSTRAYMSG = WM_USER+100;
유형
tform1 = 클래스 (tform)
lvsysproc : tlistview;
lblsysproc : tlabel;
lblaboutproc : tlabel;
lvaboutproc : tlistview;
lblcountsysproc : tlabel;
lblcountaboutproc : tlabel;
패널 1 : tpanel;
btndetermine : tbutton;
Btnrefresh : Tbutton;
lblothers : tlabel;
lblemail : tlabel;
myflag1 : tmyflag;
절차 btnrefreshclick (sender : t 객체 );
절차 btndetermineclick (sender : t 객체 );
절차 lvsysprocclick (sender : t 객체 );
프로 시저 Formcreate (sender : t 객체 );
절차 ApponMinimize (Sender : T Object );
절차 formclose (발신자 : t 객체 ; var action : tcloseacect);
절차 formdeactivate (sender : t 객체 );
절차 lblemailClick (sender : t 객체 );
프로 시저 포맷 크기 (sender : t 객체 );
사적인
{개인 선언}
Fshandle : Thandle;
formoldHeight, formoldwidth : 정수;
절차 systray onclick (var message : tmessage); 메시지 wm_systraymsg;
공공의
{공개 선언}
끝;
var
form1 : tform1;
Idid : dword;
fp32 : tprocessentry32;
fm32 : tmoduleentry32;
Systrayicon : tnotifyicondata;
구현
{$ r *.dfm}
함수 RegisterServiceProcess (DWPROCESSID, DWTYPE : Integer) : Integer; StdCall; 외부 'kernel32.dll';
절차 tform1.btnrefreshclick (sender : t 객체 );
var
CLP : bool;
Newitem1 : tlistitem;
Myicon : Ticon;
IconIndex : Word;
Procfile : char의 배열 [0..max_path];
시작하다
Myicon : = Ticon.create;
lvsysproc.items.clear;
lvsysproc.smallimages.clear;
fshandle : = CreateToolHelp32SnapShot (TH32CS_SNAPROCESS, 0);
fp32.dwsize : = sizeof (fp32);
clp : = process32first (fshandle, fp32);
iconindex : = 0;
정수 (clp) <> 0
시작하다
fp32.th32processid <> getCurrentProcessId 인 경우
시작하다
newitem1 : = lvsysproc.items.add;
{
Newitem1.caption : = fp32.szexefile;
myicon.handle : = Extracticon (form1.handle, fp32.szexefile, 0);
}
strcopy (procfile, fp32.szexefile);
newitem1.caption : = procfile;
myicon.handle : = ExtractAssissociatedIcon (Hinstance, Procfile, iconindex);
Myicon.handle <> 0이면
시작하다
lvsysproc과 함께
시작하다
newitem1.imageindex : = smallimages.addicon (myicon);
끝;
끝;
Newitem1.subitems와 함께
시작하다
추가 (inttoHex (fp32.th32processid, 4));
추가 (inttoHex (fp32.th32parentProcessId, 4));
추가 (inttoHex (fp32.pcpriclassbase, 4));
추가 (inttoHex (fp32.cntUsage, 4));
추가 (inttostr (fp32.cntthreads));
끝;
끝;
clp : = process32next (fshandle, fp32);
끝;
CloseHandle (fshandle);
lblcountsysproc.caption : = inttostr (lvsysproc.items.count);
myicon.free;
끝;
절차 tform1.btndetermineclick (sender : t 객체 );
var
ProcessHndle : Thandle;
시작하다
lvsysproc과 함께
시작하다
선택한 경우 = nil 그렇다면
시작하다
MessageBox (form1.handle, '먼저 종료 될 프로세스를 선택하십시오!', '작동 프롬프트', mb_ok+mb_iconinformation);
끝
또 다른
시작하다
if messagebox (form1.handle, pchar ( '종료'+itemfocused.caption+'?')
, '종료 프로세스', MB_YESNO+MB_ICONWARNING+MB_DEFBUTTON2) = MRYES
시작하다
Idid : = strtoint ( '$'+itemfocused.subitems [0]);
ProcessHndle : = OpenProcess (process_terminate, bool (0), idid);
정수 인 경우 (종료 프로세스 (ProcessShndle, 0)) = 0
MessageBox (form1.handle, pchar ( '+itemfocused.caption+'! ')
, '작동 실패', mb_ok+mb_ic onerror )
또 다른
시작하다
선택된 .Delete;
lvaboutproc.items.clear;
lblcountsysproc.caption : = inttostr (lvsysproc.items.count);
lblcountaboutproc.caption : = '';
끝
끝;
끝;
끝;
끝;
절차 tform1.lvsysprocclick (sender : t 객체 );
var
Newitem2 : tlistitem;
CLP : bool;
시작하다
lvsysproc.selected <> nil이면
시작하다
idid : = strtoint ( '$'+lvsysproc.itemfocused.subitems [0]);
lvaboutproc.items.clear;
fshandle : = CreateToolHelp32SnapShot (Th32cs_snapModule, idid);
fm32.dwsize : = sizeof (fm32);
clp : = module32first (fshandle, fm32);
정수 (clp) <> 0
시작하다
newitem2 : = lvaboutproc.items.add;
Newitem2와 함께
시작하다
캡션 : = fm32.szeexepath;
newitem2.subitems와 함께
시작하다
추가 (inttoHex (fm32.th32moduleid, 4));
추가 (inttoHex (fm32.glblcntusage, 4));
추가 (inttoHex (fm32.proctNusage, 4));
끝;
끝;
clp : = module32next (fshandle, fm32);
끝;
CloseHandle (fshandle);
lblcountaboutproc.caption : = inttostr (lvaboutproc.items.count);
끝
끝;
프로 시저 tform1. formcreate (sender : t 객체 );
시작하다
응용 프로그램과 함께
시작하다
showwindow (핸들, SW_HIDE); // 작업 표시 줄의 작업 버튼을 숨 깁니다
Onminimize : = Apponminimize; // 최소화되면 자동으로 숨겨져 있습니다
ondeativate : = formdeactivate;
onactivate : = btnrefreshclick;
끝;
RegisterServiceProcess (GetCurrentProcessId, 1);
Systrayicon과 함께
시작하다
cbsize : = sizeof (systrayicon);
WND : = 핸들;
uid : = systray_id;
uflags : = nif_icon 또는 nif_message 또는 nif_tip;
ucallbackmessage : = wm_systraymsg;
Hicon : = application.icon.handle;
sztip : = '시스템 프로세스 모니터링';
끝;
shell_notifyicon (nim_add,@systrayicon); // 시스템 트레이 영역에 프로그램을 추가합니다
lvsysproc과 함께
시작하다
smallimages : = timagelist.createsize (16,16);
smallimages.shareimages : = true;
끝;
formoldwidth : = self.width;
formoldHeight : = self.height;
끝;
// 최소화되면 자동으로 숨겨져 있습니다
절차 tform1.apponminimize (sender : t 객체 );
시작하다
Showwindow (Application.Handle, SW_HIDE);
끝;
// 시스템 트레이 영역 아이콘을 클릭하려면 마우스 응답
절차 tform1.systray onclick (var 메시지 : tmessage);
시작하다
메시지와 함께
시작하다
if (lparam = wm_lbuttondown) 또는 (lparam = wm_rbuttondown)
시작하다
application.restore;
setforegroundwindow (핸들);
Showwindow (Application.Handle, SW_HIDE);
끝;
끝;
끝;
절차 tform1.formclose (Sender : t 객체 ; var action : tcloseacect);
시작하다
shell_notifyicon (nim_delete,@systrayicon); // 시스템 트레이 영역을 취소합니다
RegisterServiceProcess (GetCurrentProcessId, 0);
lvsysproc.smallimages.free;
끝;
// 비활성이있을 때 자동으로 숨 깁니다
절차 tform1.formDeactivate (sender : t 객체 );
시작하다
application.minimize;
끝;
절차 tform1.lblemailClick (sender : t 객체 );
시작하다
shellexecute (핸들, 오픈 ', pchar ('mailto : [email protected] '), NIL, NIL, SW_SHOW) <33
MessageBox (form1.handle, '이메일 소프트웨어를 시작할 수 없습니다!', '죄송합니다', mb_iconinformation+mb_ok);
끝;
// 양식 크기가 변경 될 때 각 구성 요소의 위치 조정
절차 tform1.formresize (sender : t 객체 );
시작하다
Panel1이 포함됩니다.
lvsysproc과 함께
시작하다
너비 : = 너비+self.width-formoldwidth;
끝;
lvaboutproc과 함께
시작하다
높이 : = 높이+self.height-formoldHeight;
너비 : = 너비+self.width-formoldwidth;
끝;
formoldwidth : = self.width;
formoldHeight : = self.height;
끝;
끝.
위의 프로그램은 Delphi 2, Windows 95 중국어 버전, Delphi 5 및 Windows 97 중국어 버전에서 정상적으로 편집하고 실행할 수 있습니다. 궁금한 점이 있으시면 다음과 같이 이메일을 보내주십시오.
추신:
위의 코드에서 registerServiceProcess ()는 WIN 9X에만 존재하는 미공개 API 함수입니다.
MASM32를 학습 한 후 MASM32 로이 프로그램을 다시 작성하고 개선했습니다.
관심있는 친구는 최신 버전을 다운로드 할 수 있습니다.
http://www.hcny.gov.cn/netres/download/procview.rar