unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,md5, StdCtrls ;
type
TSanSvcFrm = class(TForm)
chk1: TCheckBox;
procedure FormCreate(Sender: TObject);
procedure chk1Click(Sender: TObject);
private
{ Private declarations }
procedure WndProc(var Message: TMessage); override;
public
{ Public declarations }
INTERMSG : UINT;
end;
var
SanSvcFrm: TSanSvcFrm;
IsActiveExe:Boolean;
XServerName, PathMd5:string;
implementation
{$R *.dfm}
procedure TSanSvcFrm.WndProc(var Message: TMessage);
var
FWinfo: TFlashWInfo;
begin
if (IsActiveExe) and (Message.Msg = INTERMSG) then
begin
if Message.WParam = $E218 then
begin
self.Show;
Application.Restore;
SetForegroundWindow(Application.Handle);
ShowWindow(Application.Handle, SW_SHOW);
FWinfo.cbSize := 20;
FWinfo.hwnd := Application.Handle; // 闪烁窗口的句柄
FWinfo.dwflags := FLASHW_ALL;
FWinfo.ucount := 1; // 闪烁的次数
FWinfo.dwtimeout := 0; // 速度以毫秒为单位, 0 默认为与指针闪烁的速率相同
FlashWindowEx(FWinfo); // 使它闪烁!
end
end else inherited;
end;
procedure TSanSvcFrm.chk1Click(Sender: TObject);
begin
if chk1.Checked then
begin
//这里安装服务 已 XServerName 做为服务名称。
end else begin
//这里删除服务.
end;
end;
procedure TSanSvcFrm.FormCreate(Sender: TObject);
var
TestHandle, Mutex: THandle;
begin
IsActiveExe:=False;
INTERMSG := RegisterWindowMessage(PChar(PathMd5));
PathMd5:= RivestStr (UpperCase(ParamStr(0)),0,32 );
Mutex := CreateMutex(nil, True, PChar('SAN_'+PathMd5));
if Mutex <> 0 then
begin
if GetLastError = Windows.ERROR_ALREADY_EXISTS then //如果存在另一实例
begin
Application.ShowMainForm :=False;
Closehandle(Mutex);
SendMessage(HWND_BROADCAST, INTERMSG, $E218, 0);
ExitProcess(0);
Exit;
end;
end;
IsActiveExe:=True;
XServerName:='SanSve'+PathMd5;
end;
end.
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,md5, StdCtrls ;
type
TSanSvcFrm = class(TForm)
chk1: TCheckBox;
procedure FormCreate(Sender: TObject);
procedure chk1Click(Sender: TObject);
private
{ Private declarations }
procedure WndProc(var Message: TMessage); override;
public
{ Public declarations }
INTERMSG : UINT;
end;
var
SanSvcFrm: TSanSvcFrm;
IsActiveExe:Boolean;
XServerName, PathMd5:string;
implementation
{$R *.dfm}
procedure TSanSvcFrm.WndProc(var Message: TMessage);
var
FWinfo: TFlashWInfo;
begin
if (IsActiveExe) and (Message.Msg = INTERMSG) then
begin
if Message.WParam = $E218 then
begin
self.Show;
Application.Restore;
SetForegroundWindow(Application.Handle);
ShowWindow(Application.Handle, SW_SHOW);
FWinfo.cbSize := 20;
FWinfo.hwnd := Application.Handle; // 闪烁窗口的句柄
FWinfo.dwflags := FLASHW_ALL;
FWinfo.ucount := 1; // 闪烁的次数
FWinfo.dwtimeout := 0; // 速度以毫秒为单位, 0 默认为与指针闪烁的速率相同
FlashWindowEx(FWinfo); // 使它闪烁!
end
end else inherited;
end;
procedure TSanSvcFrm.chk1Click(Sender: TObject);
begin
if chk1.Checked then
begin
//这里安装服务 已 XServerName 做为服务名称。
end else begin
//这里删除服务.
end;
end;
procedure TSanSvcFrm.FormCreate(Sender: TObject);
var
TestHandle, Mutex: THandle;
begin
IsActiveExe:=False;
INTERMSG := RegisterWindowMessage(PChar(PathMd5));
PathMd5:= RivestStr (UpperCase(ParamStr(0)),0,32 );
Mutex := CreateMutex(nil, True, PChar('SAN_'+PathMd5));
if Mutex <> 0 then
begin
if GetLastError = Windows.ERROR_ALREADY_EXISTS then //如果存在另一实例
begin
Application.ShowMainForm :=False;
Closehandle(Mutex);
SendMessage(HWND_BROADCAST, INTERMSG, $E218, 0);
ExitProcess(0);
Exit;
end;
end;
IsActiveExe:=True;
XServerName:='SanSve'+PathMd5;
end;
end.