home *** CD-ROM | disk | FTP | other *** search
- //---------------------------------------------------------------------
- #include <vcl.h>
- #pragma hdrstop
-
- #include "proc.h"
- #include "another.h"
- //---------------------------------------------------------------------
- #pragma resource "*.dfm"
- TForm1 *Form1;
- //---------------------------------------------------------------------
- static int stat=1;
- int i=0;
- //---------------------------------------------------------------------
- __fastcall TForm1::TForm1(TComponent *Owner)
- : TForm(Owner)
- {
- }
- //---------------------------------------------------------------------
- bool __stdcall EnumProc(/*HWND*/void * hWnd,/*LPARAM*/long/*lp*/)
- {
- unsigned long* pPid; //LPDWORD
- unsigned long result; //DWORD
- void *hg; //HGLOBAL
- unsigned long id;
-
- if(hWnd==NULL)
- return false;
-
- (int)hg = GlobalAlloc(GMEM_SHARE,sizeof(unsigned long));
- pPid = (unsigned long *)GlobalLock((int)hg);
-
- result = GetWindowThreadProcessId((int)hWnd,pPid);
-
- if(result){
- char title[110];
- char className[95];
- char totalStr[256];
- GetClassName((int)hWnd,className,95);
- GetWindowText((int)hWnd,title,110);
- id=*pPid;
- itoa(id,totalStr,10);
- strcat(totalStr,"\t");
- if(title){
- strcat(totalStr,title);
- strcat(totalStr,"\t");
- }
- strcat(totalStr,className);
- Form1->ListBox1->Items->Add((String)totalStr);
- }
- else{
- GlobalUnlock((int)hg);
- GlobalFree((int)hg);
- return false;
- }
- GlobalUnlock((int)hg);
- GlobalFree((int)hg);
- return true;
- }
-
- //---------------------------------------------------------------------
- void __fastcall TForm1::RadioButton3Click(TObject* /*Sender*/)
- {
-
- }
- //----------------------------------------------------------------------------
- void __fastcall TForm1::Exit1Click(TObject* /*Sender*/)
- {
- PostQuitMessage(0);
- }
- //----------------------------------------------------------------------------
- void __fastcall TForm1::About1Click(TObject* /*Sender*/)
- {
- Form2->ShowModal();
- }
- //----------------------------------------------------------------------------
- void __fastcall TForm1::SpeedButton1Click(TObject* /*Sender*/)
- {
- Exit1Click(0);
- }
- //----------------------------------------------------------------------------
- void __fastcall TForm1::SpeedButton2Click(TObject* /*Sender*/)
- {
- About1Click(0);
- }
- //----------------------------------------------------------------------------
- void __fastcall TForm1::SpeedButton4Click(TObject* /*Sender*/)
- {
- long lp=0;
- ListBox1->Enabled=true;
- ListBox1->Clear();
- EnumWindows(EnumProc,lp);
- Button2->Enabled=true;
- SpeedButton3->Enabled=true;
- }
- //----------------------------------------------------------------------------
- void __fastcall TForm1::RadioButton1Click(TObject* Sender)
- {
- TRadioButton *rbp =(TRadioButton*) Sender;
- ListBox1->Font->Color=rbp->Font->Color;
- }
- //----------------------------------------------------------------------------
- void __fastcall TForm1::Button2Click(TObject* /*Sender*/)
- {
- SpeedButton4Click(0);
- Button1->Enabled=false;
- }
- //----------------------------------------------------------------------------
- void __fastcall TForm1::Button1Click(TObject* /*Sender*/)
- {
- String str;
- char *tmp;
- int i;
- i= ListBox1->ItemIndex;
- if( i != -1){
- String s;
- tmp = new char[100];
- s=ListBox1->Items->Strings[i];
- strcpy(tmp,(char*)s.c_str());
- tmp=strtok(tmp,"\t");
- }
- int id=atoi(tmp);
- delete[] tmp;
- unsigned int ps = OpenProcess(1,false,id);
- if(ps){
- if(!TerminateProcess(ps,-9)){
- ShowMessage((String)"Could not end process specified!");
- }
- else{
- ShowMessage((String)"Process successfully terminated!");
- }
- }
- else{
- ShowMessage((String)"Could not open process requested!");
- }
- }
- //----------------------------------------------------------------------------
- void __fastcall TForm1::New1Click(TObject* /*Sender*/)
- {
- SpeedButton4Click(0);
- }
- //----------------------------------------------------------------------------
- void __fastcall TForm1::Refresh1Click(TObject* /*Sender*/)
- {
- SpeedButton4Click(0);
- }
- //----------------------------------------------------------------------------
- void __fastcall TForm1::GroupBox1Click(TObject* /*Sender*/)
- {
-
- }
- //----------------------------------------------------------------------------
- void __fastcall TForm1::FormCreate(TObject* /*Sender*/)
- {
- SpeedButton3->Glyph->LoadFromResourceName(0,(String)"IDB_ERASE");
- }
- //----------------------------------------------------------------------------
- void __fastcall TForm1::SpeedButton3Click(TObject* /*Sender*/)
- {
- ListBox1->Clear();
- SpeedButton3->Enabled=false;
- Button1->Enabled=false;
- }
- //----------------------------------------------------------------------------
- void __fastcall TForm1::ListBox1Click(TObject* /*Sender*/)
- {
- Button1->Enabled=true;
- StatusBar1->SimpleText="Select 'Kill Selected PID' to terminate the process";
- }
- //----------------------------------------------------------------------------
-
-
- void __fastcall TForm1::FormShow(TObject */*Sender*/)
- {
- if(stat){
- stat= 0;
- ListBox1->Items->Add((String)"Click on 'pid' Tool button above");
- }
- }
- //---------------------------------------------------------------------
- void __fastcall TForm1::Timer1Timer(TObject */*Sender*/)
- {
- switch(i){
- case 0:{
- Image1->Picture->Bitmap->LoadFromResourceName(0,(String)"BITMAP_5");
- Image1->Refresh();
- i=1;
- return;
- }
- case 1:{
- Image1->Picture->Bitmap->LoadFromResourceName(0,(String)"BITMAP_2");
- Image1->Refresh();
- i=2;
- return;
- }
- case 2:{
- Image1->Picture->Bitmap->LoadFromResourceName(0,(String)"BITMAP_3");
- Image1->Refresh();
- i=3;
- return;
- }
- case 3:{
- Image1->Picture->Bitmap->LoadFromResourceName(0,(String)"BITMAP_4");
- Image1->Refresh();
- i=4;
- return;
- }
- case 4:{
- Image1->Picture->Bitmap->LoadFromResourceName(0,(String)"BITMAP_1");
- Image1->Refresh();
- i=0;
- return;
- }
- }//end switch
- }
-