forked from dfdragon/kcptun_xclient
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOneCopy.pas
121 lines (103 loc) · 2.34 KB
/
OneCopy.pas
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
unit OneCopy;
interface
//** Converted with Mida BASIC 275 http://www.midaconverter.com
uses
System.SysUtils,
System.Types,
System.UITypes,
System.Classes,
System.Variants,
System.IniFiles,
Data.DB,
FMX.Types,
FMX.Controls,
FMX.Forms,
FMX.Dialogs,
FMX.Objects,
FMX.Menus,
FMX.Grid,
FMX.ExtCtrls,
FMX.ListBox,
FMX.TreeView,
FMX.Memo,
FMX.TabControl,
FMX.Layouts,
FMX.Edit,
FMX.Platform,
FMX.Bind.DBEngExt,
FMX.Bind.Editors,
FMX.Bind.DBLinks,
FMX.Bind.Navigator,
Data.Bind.EngExt,
Data.Bind.Components,
Data.Bind.DBScope,
Data.Bind.DBLinks,
Datasnap.DBClient,
Fmx.Bind.Grid,
System.Rtti,
System.Bindings.Outputs,
Data.Bind.Grid,
Fmx.StdCtrls,
FMX.Header,
FMX.Graphics,
Macapi.AppKit, Macapi.Foundation, Macapi.Helpers;
//** Original VCL Uses section :
//** Windows, Messages, SysUtils, Variants, Classes, Controls, Forms,
//** ComCtrls, ExtCtrls, StdCtrls;
//const
// MI_QueryWindowHandle = 1;
// MI_RespondWindowHandle = 2;
//
// MI_Error_None = 0;
// MI_Error_FailSubClass = 1;
// MI_Error_CreatingMutex = 2;
//
const
UniqueAppStr = 'kcptun_xclient';
//var
// MessageID: Integer;
// WProc: TFNWndProc;
// MutHandle: THandle;
// MIError: Integer;
procedure InitInstance;
implementation
procedure GetRunningApplications(Applist: TStringlist);
var
fWorkSpace: NSWorkSpace;
list: NSArray;
i: Integer;
lItem: NSDictionary;
key, value: NSString;
begin
fWorkSpace:= TNsWorkspace.Wrap(TNsWorkSpace.OCClass.sharedWorkspace);
list:= fWorkspace.launchedApplications;
if (List <> nil) and (List.count > 0) then
begin
for i := 0 to list.count - 1 do
begin
lItem:= TNSDictionary.Wrap(List.objectAtIndex(i));
// key:= NSSTR(String(PAnsiChar(UTF8Encode('NSApplicationBundleIdentifier'))));
key:= StrToNSStr(String(PAnsiChar(UTF8Encode('NSApplicationBundleIdentifier'))));
// You can also use NSApplicationPath or NSApplicationName
value:= TNSString.Wrap(lItem.valueForKey(key));
Applist.Add(String(value.UTF8String));
end;
end;
end;
procedure InitInstance;
var
Applist: TStringlist;
i: Integer;
isFind: Boolean;
begin
Applist:= TStringlist.Create;
try
GetRunningApplications(Applist);
isFind:= Applist.Find(UniqueAppStr, i);
finally
Applist.Free;
end;
if isFind then
Halt;
end;
end.