1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172:
| unit tasks1;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, tlhelp32, StdCtrls, ExtCtrls, ShellAPI, IdBaseComponent, IdComponent, IdRawBase, IdRawClient, IdIcmpClient;
type TForm1 = class(TForm) Timer1: TTimer; ListBox1: TListBox; Button1: TButton; Button2: TButton; Button3: TButton; Timer2: TTimer; ICMP: TIdIcmpClient; Timer3: TTimer; procedure FormCreate(Sender: TObject); procedure Timer1Timer(Sender: TObject); procedure Timer2Timer(Sender: TObject); procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure Button3Click(Sender: TObject); procedure Timer3Timer(Sender: TObject); procedure ICMPReply(ASender: TComponent; const AReplyStatus: TReplyStatus); private public end;
var Form1: TForm1; xx: Boolean;
implementation
{$R *.dfm}
procedure GetProcessList(sl: TStrings); var hProcSnap: THandle; pe32: TProcessEntry32; begin hProcSnap := CreateToolHelp32SnapShot(TH32CS_SNAPPROCESS, 0); if hProcSnap = INVALID_HANDLE_VALUE then exit;
pe32.dwSize := SizeOf(ProcessEntry32);
if Process32First(hProcSnap, pe32) = true then sl.Add(pe32.szExeFile); while Process32Next(hProcSnap, pe32) = true do begin sl.Add(pe32.szExeFile); if AnsiCompareStr(LowerCase(pe32.SZExeFile),LowerCase('XXX.exe')) = 0 then begin xx := true; end else begin xx := false; end end; CloseHandle(hProcSnap); end;
procedure TForm1.FormCreate(Sender: TObject); begin ListBox1.Clear; GetProcessList(ListBox1.Items); if xx = true then begin Timer1.Enabled := true; end else begin Timer2.Enabled := true; end end;
procedure TForm1.Timer1Timer(Sender: TObject); begin ListBox1.Clear; GetProcessList(ListBox1.Items); if not xx = true then begin Timer1.Enabled := false; ShellExecute(Application.Handle, 'open', 'mail.bat', nil, nil, SW_SHOW); Timer2.Enabled := true; end; end;
procedure TForm1.Timer2Timer(Sender: TObject); begin ListBox1.Clear; GetProcessList(ListBox1.Items); if xx = true then begin Timer2.Enabled := false; Timer1.Enabled := true; end; end;
procedure TForm1.Button1Click(Sender: TObject); begin Timer2.Enabled := false; Timer1.Enabled := false; ListBox1.Clear; GetProcessList(ListBox1.Items); if xx = true then begin Timer1.Enabled := true; end else begin Timer2.Enabled := true; end end;
procedure TForm1.Button2Click(Sender: TObject); begin Timer2.Enabled := false; Timer1.Enabled := false; end;
procedure TForm1.Button3Click(Sender: TObject); begin ShellExecute(Application.Handle, 'open', 'C:\XXX.exe', nil, nil, SW_SHOW); end;
procedure TForm1.Timer3Timer(Sender: TObject); i: integer; Dateiname: TStringList; begin if FileExists('XXX.txt') then begin
ICMP.OnReply := ICMPReply; i := 0; Dateiname := TStringList.Create; Dateiname.LoadFromFile('XXX.txt'); while i <= Dateiname.Count - 1 do begin ICMP.Host := Dateiname.Strings[i]; ICMP.Ping; Application.ProcessMessages; i:= i + 1; end end end;
procedure TForm1.ICMPReply(ASender: TComponent; const AReplyStatus: TReplyStatus); begin if AReplyStatus.TimeToLive = 0 then ShellExecute(Application.Handle, 'open', 'mailto.exe', nil, nil, SW_SHOW); end;
end. |