-
Notifications
You must be signed in to change notification settings - Fork 2
/
pgserver.lpr
57 lines (52 loc) · 1.25 KB
/
pgserver.lpr
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
program pgserver;
{$mode objfpc}{$H+}
{-----------------------------------------------------------------------------
Author: Zaher Dirkey
Purpose:
License: mit(https://opensource.org/licenses/MIT)
-----------------------------------------------------------------------------}
uses
{$IFDEF UNIX}
cthreads,
{$ENDIF}
{$IFDEF HASAMIGA}
athreads,
{$ENDIF}
SysUtils, StrUtils,
Interfaces, // this includes the LCL widgetset
simpleipc,
Forms, MainForms;
{$R *.res}
function IsAnotherInstance: Boolean;
var
aClient: TSimpleIPCClient;
begin
aClient := TSimpleIPCClient.Create(nil);
try
aClient.ServerID := sApplicationID;
Result := aClient.ServerRunning;//There is another instance
if Result then
begin
aClient.Connect;
try
aClient.SendStringMessage(1, 'Show');
finally
aClient.Disconnect;
end;
end
finally
aClient.Free;
end;
end;
begin
RequireDerivedFormResource :=True;
if not IsAnotherInstance then
begin
Application.Name := 'pgsrvtool';
Application.Title:='PG Server GUI';
Application.Scaled:=True;
Application.Initialize;
Application.CreateForm(TMainForm, MainForm);
Application.Run;
end;
end.