A
aKnightChen
Unregistered / Unconfirmed
GUEST, unregistred user!
麻烦大家才我看一下,
运行程序后,两次点击这个按纽,都是显示"第一次执行"...
(WINDOW2000 PRO SP4, DELPHI7)
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
aMutex: Thandle;
begin
aMutex := CreateMutex(nil, False, 'test001');
if WaitForSingleObject(aMutex, 0) <> Wait_Timeout then
SHOWMESSAGE('第一次执行!~')
else
SHOWMESSAGE('发现已执行过!');
//可以,运行程序后,两次点击这个按纽,都是显示"第一次执行"...
end;
end.
运行程序后,两次点击这个按纽,都是显示"第一次执行"...
(WINDOW2000 PRO SP4, DELPHI7)
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
aMutex: Thandle;
begin
aMutex := CreateMutex(nil, False, 'test001');
if WaitForSingleObject(aMutex, 0) <> Wait_Timeout then
SHOWMESSAGE('第一次执行!~')
else
SHOWMESSAGE('发现已执行过!');
//可以,运行程序后,两次点击这个按纽,都是显示"第一次执行"...
end;
end.