1
2 unit Unit1;
3
4 interface
5
6 uses
7 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
8 Dialogs, StdCtrls;
9
10 type
11 TForm1 = class(TForm)
12 Button1: TButton;
13 OpenDialog1: TOpenDialog;
14 procedure Button1Click(Sender: TObject);
15 private
16 { Private declarations }
17 public
18 { Public declarations }
19 end;
20
21 var
22 Form1: TForm1;
23
24 implementation
25
26 {$R *.dfm}
27
28 function ExeFileIsRunning(ExeFile:string): boolean;
29 var H:word;
30 begin
31 H := CreateFile(PChar(ExeFile), GENERIC_READ, 0, nil, OPEN_EXISTING, 0, 0);
32 Result := (H >= 65535);
33 CloseHandle(H);
34 end;
35
36
37 procedure TForm1.Button1Click(Sender: TObject);
38 begin
39 if OpenDialog1.Execute then
40 if ExeFileIsRunning(Opendialog1.FileName) then
41 ShowMessage('File is running!')
42 else
43 ShowMessage('File is NOT running!')
44 end;
45 end.
46
47
|