This repository was archived by the owner on Oct 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathInitCode.pas
More file actions
110 lines (95 loc) · 2.34 KB
/
InitCode.pas
File metadata and controls
110 lines (95 loc) · 2.34 KB
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
unit InitCode;
interface
uses
Utils, LibImport,
WinAPI.Windows,
System.SysUtils, System.Classes, System.Types, System.StrUtils;
const
PLUGIN_DATABASE = 0;
PLUGIN_CONFIG = 1;
PLUGIN_LIBRARY = 2;
PluginsParam = '-bd';
type
PUIFuncs = ^TUIFuncs;
TUIFuncs = record
IsZlibLoaded: Boolean;
IsReflateLoaded: Boolean;
IsPreflateLoaded: Boolean;
IsLZ4Loaded: Boolean;
IsLZOLoaded: Boolean;
IsZSTDLoaded: Boolean;
IsOodleLoaded: Boolean;
IsFLACLoaded: Boolean;
IsBrunsliLoaded: Boolean;
IsPackJPGLoaded: Boolean;
IsJoJpegLoaded: Boolean;
IsXDeltaLoaded: Boolean;
IsLZMALoaded: Boolean;
IsSrepAvailable: Boolean;
end;
var
DEBUG: Boolean = False;
UILib: TLibImport;
PluginsPath: String = '';
XTLUI1: procedure;
XTLUI2: function(Funcs: PUIFuncs; var Params: TArray<String>;
out LibType: Integer; out LibPath: String): Boolean;
XTLAddPlugin: procedure(S: String; I: Integer);
XTLAddCodec: procedure(S: String);
UIDLLLoaded: Boolean = False;
implementation
procedure Init;
begin
if Win32MajorVersion < 6 then
exit;
UILib := TLibImport.Create;
UILib.LoadLib(ChangeFileExt(Utils.GetModuleName, 'ui.dll'));
if UILib.Loaded then
begin
@XTLUI1 := UILib.GetProcAddr('XTLUI1');
@XTLUI2 := UILib.GetProcAddr('XTLUI2');
@XTLAddPlugin := UILib.GetProcAddr('XTLAddPlugin');
@XTLAddCodec := UILib.GetProcAddr('XTLAddCodec');
UIDLLLoaded := Assigned(XTLUI1);
end;
end;
procedure Deinit;
begin
if Win32MajorVersion < 6 then
exit;
UILib.Free;
end;
var
I: Integer;
initialization
if not IsLibrary then
begin
for I := 1 to ParamCount do
begin
if (ParamStr(I) = '--debug') then
begin
DEBUG := True;
break;
end;
end;
Init;
if UIDLLLoaded and (ParamCount = 0) then
PluginsPath := IncludeTrailingBackSlash
(ExpandPath(GetIniString('UI', 'Plugins', '',
ChangeFileExt(Utils.GetModuleName, 'ui.ini'))));
for I := 1 to ParamCount do
begin
if ParamStr(I).StartsWith(PluginsParam) then
begin
PluginsPath := ParamStr(I).Substring(PluginsParam.Length);
break;
end;
end;
end;
PluginsPath := IncludeTrailingBackSlash(ExpandPath(PluginsPath));
if not DirectoryExists(ExpandPath(PluginsPath, True)) then
PluginsPath := ExtractFilePath(Utils.GetModuleName);
finalization
if not IsLibrary then
Deinit;
end.