代码拉取完成,页面将自动刷新
unit FlatSingle;
interface
{$I FlatStyle.inc}
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
type
TFlatSingle = class(TComponent)
private
{ Private declarations }
FActive: boolean;
hmutex: Thandle;
FTitle: string;
procedure SetActive(Value: boolean);
protected
{ Protected declarations }
procedure Loaded; override;
procedure RunSingle(Single:Boolean);
public
{ Public declarations }
constructor Create(AOwner: TComponent); override;
published
{ Published declarations }
property Active: boolean read FActive write SetActive default True;
property Title: string read FTitle write FTitle;
end;
implementation
constructor TFlatSingle.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FActive := True;
FTitle := 'The program already run!';
end;
procedure TFlatSingle.Loaded;
begin
inherited Loaded;
RunSingle(Active);
end;
procedure TFlatSingle.RunSingle(Single: Boolean);
begin
if (Single)and(not(csDesigning in ComponentState)) then
begin
with Application do
begin
try
hmutex := OpenMutex(MUTEX_ALL_ACCESS, False, pchar(Title));
if hmutex = 0 then
begin
inherited;
hmutex := CreateMutex(nil, False, pchar(Title));
ReleaseMutex(hmutex);
end
else
begin
ShowMainForm := False;
ShowMessage(FTitle);
Terminate;
end;
finally
end;
end;
end;
end;
procedure TFlatSingle.SetActive(Value: boolean);
begin
FActive := Value;
RunSingle(FActive);
end;
end.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。