2
0

Shared.ScriptFunc.pas 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594
  1. unit Shared.ScriptFunc;
  2. {
  3. Inno Setup
  4. Copyright (C) 1997-2025 Jordan Russell
  5. Portions by Martijn Laan
  6. For conditions of distribution and use, see LICENSE.TXT.
  7. Script support functions (listings - used by Compil32, ISCmplr, and Setup)
  8. }
  9. interface
  10. type
  11. TScriptFuncTableID = (sftScriptDlg, sftNewDiskForm, sftBrowseFunc, sftCommonFuncVcl,
  12. sftCommonFunc, sftInstall, sftInstFunc, sftInstFuncOle, sftMainFunc, sftMessages,
  13. sftSystem, sftSysUtils, sftVerInfoFunc, sftWindows, sftActiveX, sftLoggingFunc,
  14. sftPathFunc, sftOther);
  15. TScriptTable = array of AnsiString;
  16. var
  17. ScriptFuncTables: array [TScriptFuncTableID] of TScriptTable; { Initialized below }
  18. DelphiScriptFuncTable: TScriptTable =
  19. [
  20. 'function Format(const Format: String; const Args: array of const): String;',
  21. 'function LogFmt(const S: String; const Args: array of const): String;',
  22. 'function FmtMessage(const S: String; const Args: array of String): String;',
  23. 'function FindFirst(const FileName: String; var FindRec: TFindRec): Boolean;',
  24. 'function FindNext(var FindRec: TFindRec): Boolean;',
  25. 'procedure FindClose(var FindRec: TFindRec);',
  26. 'procedure GetWindowsVersionEx(var Version: TWindowsVersion);'
  27. ];
  28. {$IFDEF COMPIL32PROJ}
  29. { These are just for Compil32 and should not be used by ISCmplr or Setup because
  30. they're already registered by TPSPascalCompiler.DefineStandardProcedures and
  31. TPSExec.RegisterStandardProc and RegisterDll_Compiletime and RegisterDLLRuntimeEx }
  32. ROPSScriptFuncTable: TScriptTable =
  33. [
  34. 'function StrToIntDef(S: String; Def: LongInt): LongInt;',
  35. 'function StrToInt(S: String): LongInt;',
  36. 'function StrToInt64Def(S: String; Def: Int64): Int64;',
  37. 'function StrToInt64(S: String): Int64;',
  38. 'function StrToFloat(S: String): Extended;',
  39. 'function IntToStr(I: Int64): String;',
  40. 'function FloatToStr(E: Extended): String;',
  41. 'function Copy(S: AnyString; Index, Count: Integer): String;',
  42. 'function Length(S: AnyString): LongInt;',
  43. 'procedure SetLength(var S: AnyString; L: LongInt);',
  44. 'function LowerCase(S: AnyString): String;',
  45. 'function UpperCase(S: AnyString): String;',
  46. 'function AnsiLowerCase(S: AnyString): String;',
  47. 'function AnsiUpperCase(S: AnyString): String;',
  48. 'function StringOfChar(C: Char; I : LongInt): String;',
  49. 'procedure Delete(var S: AnyString; Index, Count: Integer);',
  50. 'procedure Insert(Source: AnyString; var Dest: AnyString; Index: Integer);',
  51. 'function Pos(SubStr, S: AnyString): Integer;',
  52. 'function GetArrayLength(var Arr: Array): LongInt;',
  53. 'procedure SetArrayLength(var Arr: Array; I: LongInt);',
  54. 'function Trim(const S: AnyString): AnyString;',
  55. 'function Null: Variant;',
  56. 'function Unassigned: Variant;',
  57. 'function VarIsEmpty(const V: Variant): Boolean;',
  58. 'function VarIsClear(const V: Variant): Boolean;',
  59. 'function VarIsNull(const V: Variant): Boolean;',
  60. 'function VarType(const V: Variant): TVarType;',
  61. 'function VarArrayGet(var S: Variant; I: Integer): Variant;',
  62. 'procedure VarArraySet(C: Variant; I: Integer; var S: Variant);',
  63. 'function IDispatchInvoke(Self: IDispatch; PropertySet: Boolean; const Name: String; Par: array of Variant): Variant;',
  64. 'procedure UnloadDll(S: String);',
  65. 'function DllGetLastError: LongInt;',
  66. 'function Int(E: Extended): Extended;',
  67. { Special functions: undocumented but listing anyway }
  68. 'function Low(var X): Int64;',
  69. 'function High(var X): Int64;',
  70. 'procedure Dec(var X: Ordinal);',
  71. 'procedure Inc(var X: Ordinal);',
  72. 'procedure Include(var S: Set; I: Ordinal);',
  73. 'procedure Exclude(var S: Set; I: Ordinal);',
  74. 'function SizeOf(var X): LongInt;',
  75. { Special: keywords instead of functions in ROPS but are presented and documented as functions by us }
  76. 'function Chr(B: Byte): Char;',
  77. 'function Ord(C: Char): Byte;',
  78. 'procedure Exit;'
  79. ];
  80. { ROPSUndocumentedScriptFuncTable: TScriptTable =
  81. [
  82. 'function StrGet(var S: String; I: Integer): Char;',
  83. 'function StrGet2(S: String; I: Integer): Char;',
  84. 'procedure StrSet(C: Char; I: Integer; var S: String);',
  85. 'function WStrGet(var S: AnyString; I: Integer): WideChar;',
  86. 'procedure WStrSet(C: AnyString; I: Integer; var S: AnyString);',
  87. 'function Sin(E: Extended): Extended;',
  88. 'function Cos(E: Extended): Extended;',
  89. 'function Sqrt(E: Extended): Extended;',
  90. 'function Int(E: Extended): Extended;',
  91. 'function Pi: Extended;',
  92. 'function Abs(E: Extended): Extended;',
  93. 'function PadL(S: AnyString; I: LongInt): AnyString;',
  94. 'function PadR(S: AnyString; I: LongInt): AnyString;',
  95. 'function PadZ(S: AnyString; I: LongInt): AnyString;',
  96. 'function Replicate(C: Char; I: LongInt): String;',
  97. 'procedure RaiseLastException;',
  98. 'procedure RaiseException(Ex: TIFException; Param: String);',
  99. 'function ExceptionType: TIFException;',
  100. 'function ExceptionParam: String;',
  101. 'function ExceptionProc: Cardinal;',
  102. 'function ExceptionPos: Cardinal;',
  103. 'function ExceptionToString(er: TIFException; Param: String): String;',
  104. 'function Int64ToStr(I: Int64): String;'
  105. ]; }
  106. {$ENDIF}
  107. type
  108. TScriptFuncHeaderKind = (hkFunction, hkProcedure, hkConstructor);
  109. function ScriptFuncHasParameters(const ScriptFunc: AnsiString): Boolean;
  110. function RemoveScriptFuncHeader(const ScriptFunc: AnsiString): AnsiString; overload;
  111. function RemoveScriptFuncHeader(const ScriptFunc: AnsiString; out Kind: TScriptFuncHeaderKind): AnsiString; overload;
  112. function ExtractScriptFuncWithoutHeaderName(const ScriptFuncWithoutHeader: AnsiString): AnsiString;
  113. function ExtractScriptFuncName(const ScriptFunc: AnsiString): AnsiString;
  114. implementation
  115. uses
  116. SysUtils, AnsiStrings;
  117. function ScriptFuncHasParameters(const ScriptFunc: AnsiString): Boolean;
  118. begin
  119. const C: AnsiString = '(';
  120. Result := Pos(C, ScriptFunc) <> 0;
  121. end;
  122. function RemoveScriptFuncHeader(const ScriptFunc: AnsiString): AnsiString;
  123. begin
  124. var Dummy: TScriptFuncHeaderKind;
  125. Result := RemoveScriptFuncHeader(ScriptFunc, Dummy);
  126. end;
  127. function RemoveScriptFuncHeader(const ScriptFunc: AnsiString; out Kind: TScriptFuncHeaderKind): AnsiString;
  128. begin
  129. Result := ScriptFunc;
  130. const H1: AnsiString = 'function ';
  131. const H2: AnsiString = 'procedure ';
  132. const H3: AnsiString = 'constructor ';
  133. if SameText(Copy(Result, 1, Length(H1)), H1) then begin
  134. Kind := hkFunction;
  135. Delete(Result, 1, Length(H1))
  136. end else if SameText(Copy(Result, 1, Length(H2)), H2) then begin
  137. Kind := hkProcedure;
  138. Delete(Result, 1, Length(H2))
  139. end else if SameText(Copy(Result, 1, Length(H3)), H3) then begin
  140. Kind := hkConstructor;
  141. Delete(Result, 1, Length(H3))
  142. end else
  143. raise Exception.CreateFmt('Invalid ScriptFunc: %s', [Result]);
  144. end;
  145. { Also present in UIsxclassesParser.pas }
  146. function ExtractScriptFuncWithoutHeaderName(const ScriptFuncWithoutHeader: AnsiString): AnsiString;
  147. begin
  148. Result := ScriptFuncWithoutHeader;
  149. const C1: AnsiString = '(';
  150. const C2: AnsiString = ':';
  151. const C3: AnsiString = ';';
  152. var P := Pos(C1, Result);
  153. if P = 0 then
  154. P := Pos(C2, Result);
  155. if P = 0 then
  156. P := Pos(C3, Result);
  157. if P = 0 then
  158. raise Exception.CreateFmt('Invalid ScriptFuncWithoutHeader: %s', [Result]);
  159. Delete(Result, P, Maxint);
  160. end;
  161. function ExtractScriptFuncName(const ScriptFunc: AnsiString): AnsiString;
  162. begin
  163. Result := ExtractScriptFuncWithoutHeaderName(RemoveScriptFuncHeader(ScriptFunc));
  164. end;
  165. {$IFDEF COMPIL32PROJ}
  166. {$IFDEF DEBUG}
  167. function IsCleanScriptFunc(const ScriptFunc: AnsiString): Boolean;
  168. begin
  169. const GoodTerminator: AnsiString = ';';
  170. const BadType1: AnsiString = 'string';
  171. const BadType2: AnsiString = 'Longint';
  172. Result := (Pos(GoodTerminator, ScriptFunc) <> 0) and
  173. (Pos(BadType1, ScriptFunc) = 0) and (Pos(BadType2, ScriptFunc) = 0) and
  174. (ScriptFunc[Length(ScriptFunc)] = ';');
  175. end;
  176. procedure CheckIsCleanScriptFuncTable(const ScriptFuncTable: TScriptTable);
  177. begin
  178. if Length(ScriptFuncTable) = 0 then
  179. raise Exception.Create('Length(ScriptFuncTable) = 0');
  180. for var AScriptFunc in ScriptFuncTable do
  181. if not IsCleanScriptFunc(AScriptFunc) then
  182. raise Exception.CreateFmt('not IsCleanScriptFunc: %s', [AScriptFunc]);
  183. end;
  184. {$ENDIF}
  185. {$ENDIF}
  186. initialization
  187. ScriptFuncTables[sftScriptDlg] :=
  188. [
  189. 'function PageFromID(const ID: Integer): TWizardPage;',
  190. 'function PageIndexFromID(const ID: Integer): Integer;',
  191. 'function CreateCustomPage(const AfterID: Integer; const ACaption, ADescription: String): TWizardPage;',
  192. 'function CreateInputQueryPage(const AfterID: Integer; const ACaption, ADescription, ASubCaption: String): TInputQueryWizardPage;',
  193. 'function CreateInputOptionPage(const AfterID: Integer; const ACaption, ADescription, ASubCaption: String; Exclusive, ListBox: Boolean): TInputOptionWizardPage;',
  194. 'function CreateInputDirPage(const AfterID: Integer; const ACaption, ADescription, ASubCaption: String; AAppendDir: Boolean; ANewFolderName: String): TInputDirWizardPage;',
  195. 'function CreateInputFilePage(const AfterID: Integer; const ACaption, ADescription, ASubCaption: String): TInputFileWizardPage;',
  196. 'function CreateOutputMsgPage(const AfterID: Integer; const ACaption, ADescription, AMsg: String): TOutputMsgWizardPage;',
  197. 'function CreateOutputMsgMemoPage(const AfterID: Integer; const ACaption, ADescription, ASubCaption: String; const AMsg: AnsiString): TOutputMsgMemoWizardPage;',
  198. 'function CreateOutputProgressPage(const ACaption, ADescription: String): TOutputProgressWizardPage;',
  199. 'function CreateOutputMarqueeProgressPage(const ACaption, ADescription: String): TOutputMarqueeProgressWizardPage;',
  200. 'function CreateDownloadPage(const ACaption, ADescription: String; const OnDownloadProgress: TOnDownloadProgress): TDownloadWizardPage;',
  201. 'function CreateExtractionPage(const ACaption, ADescription: String; const OnExtractionProgress: TOnExtractionProgress): TExtractionWizardPage;',
  202. 'function ScaleX(X: Integer): Integer;',
  203. 'function ScaleY(Y: Integer): Integer;',
  204. 'function CreateCustomForm(const ClientWidth, ClientHeight: Integer; const KeepSizeX, KeepSizeY: Boolean): TSetupForm;'
  205. ];
  206. ScriptFuncTables[sftNewDiskForm] :=
  207. [
  208. 'function SelectDisk(const DiskNumber: Integer; const AFilename: String; var Path: String): Boolean;'
  209. ];
  210. ScriptFuncTables[sftBrowseFunc] :=
  211. [
  212. 'function BrowseForFolder(const Prompt: String; var Directory: String; const NewFolderButton: Boolean): Boolean;',
  213. 'function GetOpenFileName(const Prompt: String; var FileName: String; const InitialDirectory, Filter, DefaultExtension: String): Boolean;',
  214. 'function GetOpenFileNameMulti(const Prompt: String; const FileNameList: TStrings; const InitialDirectory, Filter, DefaultExtension: String): Boolean;',
  215. 'function GetSaveFileName(const Prompt: String; var FileName: String; const InitialDirectory, Filter, DefaultExtension: String): Boolean;'
  216. ];
  217. ScriptFuncTables[sftCommonFuncVcl] :=
  218. [
  219. 'function MinimizePathName(const Filename: String; const Font: TFont; MaxLen: Integer): String;'
  220. ];
  221. ScriptFuncTables[sftCommonFunc] :=
  222. [
  223. 'function FileExists(const Name: String): Boolean;',
  224. 'function DirExists(const Name: String): Boolean;',
  225. 'function FileOrDirExists(const Name: String): Boolean;',
  226. 'function GetIniString(const Section, Key, Default, Filename: String): String;',
  227. 'function GetIniInt(const Section, Key: String; const Default, Min, Max: LongInt; const Filename: String): LongInt;',
  228. 'function GetIniBool(const Section, Key: String; const Default: Boolean; const Filename: String): Boolean;',
  229. 'function IniKeyExists(const Section, Key, Filename: String): Boolean;',
  230. 'function IsIniSectionEmpty(const Section, Filename: String): Boolean;',
  231. 'function SetIniString(const Section, Key, Value, Filename: String): Boolean;',
  232. 'function SetIniInt(const Section, Key: String; const Value: LongInt; const Filename: String): Boolean;',
  233. 'function SetIniBool(const Section, Key: String; const Value: Boolean; const Filename: String): Boolean;',
  234. 'procedure DeleteIniEntry(const Section, Key, Filename: String);',
  235. 'procedure DeleteIniSection(const Section, Filename: String);',
  236. 'function GetEnv(const EnvVar: String): String;',
  237. 'function GetCmdTail: String;',
  238. 'function ParamCount: Integer;',
  239. 'function ParamStr(Index: Integer): String;',
  240. 'function AddQuotes(const S: String): String;',
  241. 'function RemoveQuotes(const S: String): String;',
  242. 'function GetShortName(const LongName: String): String;',
  243. 'function GetWinDir: String;',
  244. 'function GetSystemDir: String;',
  245. 'function GetSysWow64Dir: String;',
  246. 'function GetSysNativeDir: String;',
  247. 'function GetTempDir: String;',
  248. 'function StringChange(var S: String; const FromStr, ToStr: String): Integer;',
  249. 'function StringChangeEx(var S: String; const FromStr, ToStr: String; const SupportDBCS: Boolean): Integer;',
  250. 'function UsingWinNT: Boolean;',
  251. 'function CopyFile(const ExistingFile, NewFile: String; const FailIfExists: Boolean): Boolean;',
  252. 'function FileCopy(const ExistingFile, NewFile: String; const FailIfExists: Boolean): Boolean;', { old name of CopyFile }
  253. 'function ConvertPercentStr(var S: String): Boolean;',
  254. 'function RegValueExists(const RootKey: Integer; const SubKeyName, ValueName: String): Boolean;',
  255. 'function RegQueryStringValue(const RootKey: Integer; const SubKeyName, ValueName: String; var ResultStr: String): Boolean;',
  256. 'function RegQueryMultiStringValue(const RootKey: Integer; const SubKeyName, ValueName: String; var ResultStr: String): Boolean;',
  257. 'function RegDeleteKeyIncludingSubkeys(const RootKey: Integer; const SubkeyName: String): Boolean;',
  258. 'function RegDeleteKeyIfEmpty(const RootKey: Integer; const SubkeyName: String): Boolean;',
  259. { Not really in CommonFunc }
  260. 'function RegKeyExists(const RootKey: Integer; const SubKeyName: String): Boolean;',
  261. 'function RegDeleteValue(const RootKey: Integer; const SubKeyName, ValueName: String): Boolean;',
  262. 'function RegGetSubkeyNames(const RootKey: Integer; const SubKeyName: String; var Names: TArrayOfString): Boolean;',
  263. 'function RegGetValueNames(const RootKey: Integer; const SubKeyName: String; var Names: TArrayOfString): Boolean;',
  264. 'function RegQueryDWordValue(const RootKey: Integer; const SubKeyName, ValueName: String; var ResultDWord: Cardinal): Boolean;',
  265. 'function RegQueryBinaryValue(const RootKey: Integer; const SubKeyName, ValueName: String; var ResultStr: AnsiString): Boolean;',
  266. 'function RegWriteStringValue(const RootKey: Integer; const SubKeyName, ValueName, Data: String): Boolean;',
  267. 'function RegWriteExpandStringValue(const RootKey: Integer; const SubKeyName, ValueName, Data: String): Boolean;',
  268. 'function RegWriteMultiStringValue(const RootKey: Integer; const SubKeyName, ValueName, Data: String): Boolean;',
  269. 'function RegWriteDWordValue(const RootKey: Integer; const SubKeyName, ValueName: String; const Data: Cardinal): Boolean;',
  270. 'function RegWriteBinaryValue(const RootKey: Integer; const SubKeyName, ValueName: String; const Data: AnsiString): Boolean;',
  271. //
  272. 'function IsAdmin: Boolean;',
  273. 'function IsAdminLoggedOn: Boolean;', { old name of IsAdmin }
  274. 'function IsPowerUserLoggedOn: Boolean;',
  275. 'function IsAdminInstallMode: Boolean;',
  276. 'function FontExists(const FaceName: String): Boolean;',
  277. 'function GetUILanguage: Integer;',
  278. 'function AddPeriod(const S: String): String;',
  279. 'function SetNTFSCompression(const FileOrDir: String; Compress: Boolean): Boolean;',
  280. 'function IsWildcard(const Pattern: String): Boolean;',
  281. 'function WildcardMatch(const Text, Pattern: String): Boolean;',
  282. 'function HighContrastActive: Boolean;'
  283. ];
  284. ScriptFuncTables[sftPathFunc] :=
  285. [
  286. 'function AddBackslash(const S: String): String;',
  287. 'function RemoveBackslash(const S: String): String;',
  288. 'function RemoveBackslashUnlessRoot(const S: String): String;',
  289. 'function PathCombine(const Dir, Filename: String): String;',
  290. 'function PathHasInvalidCharacters(const S: String; const AllowDriveLetterColon: Boolean): Boolean;',
  291. 'function PathIsRooted(const Filename: String): Boolean;',
  292. 'function PathNormalizeSlashes(const S: String): String;',
  293. 'function PathSame(const S1, S2: String): Boolean;',
  294. 'function PathStartsWith(const S, AStartsWith: String; const IgnoreCase: Boolean): Boolean;',
  295. 'function PathEndsWith(const S, AEndsWith: String; const IgnoreCase: Boolean): Boolean;',
  296. { All in PathFunc but with a different name }
  297. 'function CharLength(const S: String; const Index: Integer): Integer;',
  298. 'function ExpandFileName(const FileName: String): String;',
  299. 'function ExtractFileDir(const FileName: String): String;',
  300. 'function ExtractFileDrive(const FileName: String): String;',
  301. 'function ExtractFileExt(const FileName: String): String;',
  302. 'function ExtractFileName(const FileName: String): String;',
  303. 'function ExtractFilePath(const FileName: String): String;',
  304. 'function ChangeFileExt(const FileName, Extension: String): String;'
  305. ];
  306. ScriptFuncTables[sftInstall] :=
  307. [
  308. 'procedure ExtractTemporaryFile(const FileName: String);',
  309. 'function ExtractTemporaryFiles(const Pattern: String): Integer;',
  310. 'function DownloadTemporaryFile(const Url, BaseName, RequiredSHA256OfFile: String; const OnDownloadProgress: TOnDownloadProgress): Int64;',
  311. 'function DownloadTemporaryFileWithISSigVerify(const Url, ISSigUrl, BaseName: String; const AllowedKeysRuntimeIDs: TStringList; const OnDownloadProgress: TOnDownloadProgress): Int64;',
  312. 'function DownloadTemporaryFileSize(const Url: String): Int64;',
  313. 'function DownloadTemporaryFileDate(const Url: String): String;',
  314. 'procedure SetDownloadCredentials(const User, Pass: String);'
  315. ];
  316. ScriptFuncTables[sftInstFunc] :=
  317. [
  318. 'function CheckForMutexes(Mutexes: String): Boolean;',
  319. 'function DecrementSharedCount(const Is64Bit: Boolean; const Filename: String): Boolean;',
  320. 'procedure DelayDeleteFile(const Filename: String; const Tries: Integer);',
  321. 'function DelTree(const Path: String; const IsDir, DeleteFiles, DeleteSubdirsAlso: Boolean): Boolean;',
  322. 'function GenerateUniqueName(Path: String; const Extension: String): String;',
  323. 'function GetComputerNameString: String;',
  324. //function GetFileDateTime(const Filename: String; var DateTime: TFileTime): Boolean;
  325. 'function GetMD5OfFile(const Filename: String): String;',
  326. 'function GetMD5OfString(const S: AnsiString): String;',
  327. 'function GetMD5OfUnicodeString(const S: String): String;',
  328. 'function GetSHA1OfFile(const Filename: String): String;',
  329. 'function GetSHA1OfString(const S: AnsiString): String;',
  330. 'function GetSHA1OfUnicodeString(const S: String): String;',
  331. 'function GetSHA256OfFile(const Filename: String): String;',
  332. 'function GetSHA256OfStream(const Stream: TStream): String;',
  333. 'function GetSHA256OfString(const S: AnsiString): String;',
  334. 'function GetSHA256OfUnicodeString(const S: String): String;',
  335. 'function GetSpaceOnDisk(const DriveRoot: String; const InMegabytes: Boolean; var Free, Total: Cardinal): Boolean;',
  336. 'function GetSpaceOnDisk64(const DriveRoot: String; var Free, Total: Int64): Boolean;',
  337. 'function GetUserNameString: String;',
  338. //function GrantPermissionOnFile(const Filename: String; const Entries: TGrantPermissionEntry; const EntryCount: Integer): Boolean;
  339. //function GrantPermissionOnKey(const RootKey: HKEY; const Subkey: String; const Entries: TGrantPermissionEntry; const EntryCount: Integer): Boolean;
  340. 'procedure IncrementSharedCount(const Is64Bit: Boolean; const Filename: String; const AlreadyExisted: Boolean);',
  341. 'function Exec(const Filename, Params, WorkingDir: String; const ShowCmd: Integer; const Wait: TExecWait; var ResultCode: Integer): Boolean;',
  342. 'function ExecAndCaptureOutput(const Filename, Params, WorkingDir: String; const ShowCmd: Integer; const Wait: TExecWait; var ResultCode: Integer; var Output: TExecOutput): Boolean;',
  343. 'function ExecAndLogOutput(const Filename, Params, WorkingDir: String; const ShowCmd: Integer; const Wait: TExecWait; var ResultCode: Integer; const OnLog: TOnLog): Boolean;',
  344. 'function ExecAsOriginalUser(const Filename, Params, WorkingDir: String; const ShowCmd: Integer; const Wait: TExecWait; var ResultCode: Integer): Boolean;',
  345. 'function ShellExec(const Verb, Filename, Params, WorkingDir: String; const ShowCmd: Integer; const Wait: TExecWait; var ErrorCode: Integer): Boolean;',
  346. 'function ShellExecAsOriginalUser(const Verb, Filename, Params, WorkingDir: String; const ShowCmd: Integer; const Wait: TExecWait; var ErrorCode: Integer): Boolean;',
  347. 'function IsProtectedSystemFile(const Filename: String): Boolean;',
  348. 'function MakePendingFileRenameOperationsChecksum: String;',
  349. 'function ModifyPifFile(const Filename: String; const CloseOnExit: Boolean): Boolean;',
  350. 'procedure RegisterServer(const Is64Bit: Boolean; const Filename: String; const FailCriticalErrors: Boolean);',
  351. 'function UnregisterServer(const Is64Bit: Boolean; const Filename: String; const FailCriticalErrors: Boolean): Boolean;',
  352. 'procedure UnregisterFont(const FontName, FontFilename: String; const PerUserFont: Boolean);',
  353. //procedure RestartComputer;
  354. 'procedure RestartReplace(const TempFile, DestFile: String);',
  355. //procedure Win32ErrorMsg(const FunctionName: String);
  356. 'function ForceDirectories(Dir: String): Boolean;'
  357. ];
  358. ScriptFuncTables[sftInstFuncOle] :=
  359. [
  360. 'function CreateShellLink(const Filename, Description, ShortcutTo, Parameters, WorkingDir, IconFilename: String; const IconIndex, ShowCmd: Integer): String;',
  361. 'procedure RegisterTypeLibrary(const Is64Bit: Boolean; const Filename: String);',
  362. 'function UnregisterTypeLibrary(const Is64Bit: Boolean; const Filename: String): Boolean;',
  363. 'function UnpinShellLink(const Filename: String): Boolean;'
  364. ];
  365. ScriptFuncTables[sftMainFunc] :=
  366. [
  367. 'function ActiveLanguage: String;',
  368. 'function ExpandConstant(const S: String): String;',
  369. 'function ExpandConstantEx(const S: String; const CustomConst, CustomValue: String): String;',
  370. 'function ExitSetupMsgBox: Boolean;',
  371. 'function GetShellFolderByCSIDL(const Folder: Integer; const Create: Boolean): String;',
  372. 'function InstallOnThisVersion(const MinVersion, OnlyBelowVersion: String): Boolean;',
  373. 'function GetWindowsVersion: Cardinal;',
  374. 'function GetWindowsVersionString: String;',
  375. 'function MsgBox(const Text: String; const Typ: TMsgBoxType; const Buttons: Integer): Integer;',
  376. 'function SuppressibleMsgBox(const Text: String; const Typ: TMsgBoxType; const Buttons, Default: Integer): Integer;',
  377. 'function TaskDialogMsgBox(const Instruction, Text: String; const Typ: TMsgBoxType; const Buttons: Cardinal; const ButtonLabels: TArrayOfString; const ShieldButton: Integer): Integer;',
  378. 'function SuppressibleTaskDialogMsgBox(const Instruction, Text: String; const Typ: TMsgBoxType; const Buttons: Cardinal; const ButtonLabels: TArrayOfString; const ShieldButton: Integer;'+' const Default: Integer): Integer;',
  379. 'function IsWin64: Boolean;',
  380. 'function Is64BitInstallMode: Boolean;',
  381. 'function IsWinDark: Boolean;',
  382. 'function IsDarkInstallMode: Boolean;',
  383. 'function ProcessorArchitecture: TSetupProcessorArchitecture;',
  384. 'function IsArm32Compatible: Boolean;',
  385. 'function IsArm64: Boolean;',
  386. 'function IsX64: Boolean;',
  387. 'function IsX64OS: Boolean;',
  388. 'function IsX64Compatible: Boolean;',
  389. 'function IsX86: Boolean;',
  390. 'function IsX86OS: Boolean;',
  391. 'function IsX86Compatible: Boolean;',
  392. 'function CustomMessage(const MsgName: String): String;',
  393. 'function RmSessionStarted: Boolean;',
  394. 'function RegisterExtraCloseApplicationsResource(const DisableFsRedir: Boolean; const AFilename: String): Boolean;',
  395. { Actually in Setup.WizardForm }
  396. 'function GetWizardForm: TWizardForm;',
  397. 'function WizardIsComponentSelected(const Components: String): Boolean;',
  398. 'function IsComponentSelected(const Components: String): Boolean;', { old name of WizardIsComponentSelected }
  399. 'function WizardIsTaskSelected(const Tasks: String): Boolean;',
  400. 'function IsTaskSelected(const Tasks: String): Boolean;' { old name of WizardIsTaskSelected }
  401. ];
  402. ScriptFuncTables[sftMessages] :=
  403. [
  404. 'function SetupMessage(const ID: TSetupMessageID): String;'
  405. ];
  406. ScriptFuncTables[sftSystem] :=
  407. [
  408. 'function Random(const Range: Integer): Integer;',
  409. 'function FileSize(const Name: String; var Size: Integer): Boolean;',
  410. 'function FileSize64(const Name: String; var Size: Int64): Boolean;',
  411. 'procedure Set8087CW(NewCW: Word);',
  412. 'function Get8087CW: Word;',
  413. 'function UTF8Encode(const S: String): AnsiString;',
  414. 'function UTF8Decode(const S: AnsiString): String;'
  415. ];
  416. ScriptFuncTables[sftSysUtils] :=
  417. [
  418. 'procedure Beep;',
  419. 'function TrimLeft(const S: String): String;',
  420. 'function TrimRight(const S: String): String;',
  421. 'function GetCurrentDir: String;',
  422. 'function SetCurrentDir(const Dir: String): Boolean;',
  423. 'function ExpandUNCFileName(const FileName: String): String;',
  424. 'function FileSearch(const Name, DirList: String): String;',
  425. 'function RenameFile(const OldName, NewName: String): Boolean;',
  426. 'function DeleteFile(const FileName: String): Boolean;',
  427. 'function CreateDir(const Dir: String): Boolean;',
  428. 'function RemoveDir(const Dir: String): Boolean;',
  429. 'function CompareStr(const S1, S2: String): Integer;',
  430. 'function CompareText(const S1, S2: String): Integer;',
  431. 'function SameStr(const S1, S2: String): Boolean;',
  432. 'function SameText(const S1, S2: String): Boolean;',
  433. 'function GetDateTimeString(const DateTimeFormat: String; const DateSeparator, TimeSeparator: Char): String;',
  434. 'function SysErrorMessage(ErrorCode: Integer): String;',
  435. { Actually NewExtractRelativePath, and not from SysUtils }
  436. 'function ExtractRelativePath(const BaseName, DestName: String): String;'
  437. ];
  438. ScriptFuncTables[sftVerInfoFunc] :=
  439. [
  440. 'function GetVersionNumbers(const Filename: String; var VersionMS, VersionLS: Cardinal): Boolean;',
  441. 'function GetVersionComponents(const Filename: String; var Major, Minor, Revision, Build: Word): Boolean;',
  442. 'function GetVersionNumbersString(const Filename: String; var Version: String): Boolean;',
  443. 'function GetPackedVersion(const Filename: String; var Version: Int64): Boolean;',
  444. 'function PackVersionNumbers(const VersionMS, VersionLS: Cardinal): Int64;',
  445. 'function PackVersionComponents(const Major, Minor, Revision, Build: Word): Int64;',
  446. 'function ComparePackedVersion(const Version1, Version2: Int64): Integer;',
  447. 'function SamePackedVersion(const Version1, Version2: Int64): Boolean;',
  448. 'procedure UnpackVersionNumbers(const Version: Int64; var VersionMS, VersionLS: Cardinal);',
  449. 'procedure UnpackVersionComponents(const Version: Int64; var Major, Minor, Revision, Build: Word);',
  450. 'function VersionToStr(const Version: Int64): String;',
  451. 'function StrToVersion(const VersionString: String; var Version: Int64): Boolean;'
  452. ];
  453. ScriptFuncTables[sftWindows] :=
  454. [
  455. 'procedure Sleep(const Milliseconds: LongInt);',
  456. 'function FindWindowByClassName(const ClassName: String): HWND;',
  457. 'function FindWindowByWindowName(const WindowName: String): HWND;',
  458. 'function SendMessage(const Wnd: HWND; const Msg, WParam, LParam: LongInt): LongInt;',
  459. 'function PostMessage(const Wnd: HWND; const Msg, WParam, LParam: LongInt): Boolean;',
  460. 'function SendNotifyMessage(const Wnd: HWND; const Msg, WParam, LParam: LongInt): Boolean;',
  461. 'function RegisterWindowMessage(const Name: String): LongInt;',
  462. 'function SendBroadcastMessage(const Msg, WParam, LParam: LongInt): LongInt;',
  463. 'function PostBroadcastMessage(const Msg, WParam, LParam: LongInt): Boolean;',
  464. 'function SendBroadcastNotifyMessage(const Msg, WParam, LParam: LongInt): Boolean;',
  465. 'function LoadDLL(const DLLName: String; var ErrorCode: Integer): LongInt;',
  466. 'function CallDLLProc(const DLLHandle: LongInt; const ProcName: String; const Param1, Param2: LongInt; var Result: LongInt): Boolean;',
  467. 'function FreeDLL(const DLLHandle: LongInt): Boolean;',
  468. 'procedure CreateMutex(const Name: String);',
  469. 'procedure OemToCharBuff(var S: AnsiString);',
  470. 'procedure CharToOemBuff(var S: AnsiString);'
  471. ];
  472. ScriptFuncTables[sftActiveX] :=
  473. [
  474. 'procedure CoFreeUnusedLibraries;'
  475. ];
  476. ScriptFuncTables[sftLoggingFunc] :=
  477. [
  478. 'procedure Log(const S: String);'
  479. ];
  480. ScriptFuncTables[sftOther] :=
  481. [
  482. 'procedure BringToFrontAndRestore;',
  483. 'function WizardDirValue: String;',
  484. 'function WizardGroupValue: String;',
  485. 'function WizardNoIcons: Boolean;',
  486. 'function WizardSetupType(const Description: Boolean): String;',
  487. 'function WizardSelectedComponents(const Descriptions: Boolean): String;',
  488. 'function WizardSelectedTasks(const Descriptions: Boolean): String;',
  489. 'procedure WizardSelectComponents(const Components: String);',
  490. 'procedure WizardSelectTasks(const Tasks: String);',
  491. 'procedure WizardSetBackImage(const BackImages: TArrayOfGraphic; const Stretch, Center: Boolean; const Opacity: Byte);',
  492. 'function WizardSilent: Boolean;',
  493. 'function IsUninstaller: Boolean;',
  494. 'function UninstallSilent: Boolean;',
  495. 'function CurrentFilename: String;',
  496. 'function CurrentSourceFilename: String;',
  497. 'function CastStringToInteger(var S: String): LongInt;',
  498. 'function CastIntegerToString(const L: LongInt): String;',
  499. 'procedure Abort;',
  500. 'function GetExceptionMessage: String;',
  501. 'procedure RaiseException(const Msg: String);',
  502. 'procedure ShowExceptionMessage;',
  503. 'function Terminated: Boolean;',
  504. 'function GetPreviousData(const ValueName, DefaultValueData: String): String;',
  505. 'function SetPreviousData(const PreviousDataKey: Integer; const ValueName, ValueData: String): Boolean;',
  506. 'function LoadStringFromFile(const FileName: String; var S: AnsiString): Boolean;',
  507. 'function LoadStringFromLockedFile(const FileName: String; var S: AnsiString): Boolean;',
  508. 'function LoadStringsFromFile(const FileName: String; var S: TArrayOfString): Boolean;',
  509. 'function LoadStringsFromLockedFile(const FileName: String; var S: TArrayOfString): Boolean;',
  510. 'function SaveStringToFile(const FileName: String; const S: AnsiString; const Append: Boolean): Boolean;',
  511. 'function SaveStringsToFile(const FileName: String; const S: TArrayOfString; const Append: Boolean): Boolean;',
  512. 'function SaveStringsToUTF8File(const FileName: String; const S: TArrayOfString; const Append: Boolean): Boolean;',
  513. 'function SaveStringsToUTF8FileWithoutBOM(const FileName: String; const S: TArrayOfString; const Append: Boolean): Boolean;',
  514. 'function EnableFsRedirection(const Enable: Boolean): Boolean;',
  515. 'function GetUninstallProgressForm: TUninstallProgressForm;',
  516. 'function CreateCallback(Method: AnyMethod): Longword;',
  517. 'function IsDotNetInstalled(const MinVersion: TDotNetVersion; const MinServicePack: Cardinal): Boolean;',
  518. 'function IsMsiProductInstalled(const UpgradeCode: String; const PackedMinVersion: Int64): Boolean;',
  519. 'function InitializeBitmapButtonFromIcon(const BitmapButton: TBitmapButton; const IconFilename: String; const BkColor: TColor; const AscendingTrySizes: TArrayOfInteger): Boolean;',
  520. 'function InitializeBitmapImageFromIcon(const BitmapImage: TBitmapImage; const IconFilename: String; const BkColor: TColor; const AscendingTrySizes: TArrayOfInteger): Boolean;',
  521. 'function InitializeBitmapButtonFromStockIcon(const BitmapButton: TBitmapButton; const Siid: Integer; const BkColor: TColor; const AscendingTrySizes: TArrayOfInteger): Boolean;',
  522. 'function InitializeBitmapImageFromStockIcon(const BitmapImage: TBitmapImage; const Siid: Integer; const BkColor: TColor; const AscendingTrySizes: TArrayOfInteger): Boolean;',
  523. 'procedure Extract7ZipArchive(const ArchiveFileName, DestDir: String; const FullPaths: Boolean; const OnExtractionProgress: TOnExtractionProgress);',
  524. 'procedure ExtractArchive(const ArchiveFilename, DestDir, Password: String; const FullPaths: Boolean; const OnExtractionProgress: TOnExtractionProgress);',
  525. 'procedure MapArchiveExtensions(const DestExt, SourceExt: String);',
  526. 'function Debugging: Boolean;',
  527. 'function StringJoin(const Separator: String; const Values: TArrayOfString): String;',
  528. 'function StringSplit(const S: String; const Separators: TArrayOfString; const Typ: TSplitType): TArrayOfString;',
  529. 'function StringSplitEx(const S: String; const Separators: TArrayOfString; const Quote: Char; const Typ: TSplitType): TArrayOfString;',
  530. 'function ISSigVerify(const AllowedKeysRuntimeIDs: TStringList; const Filename: String; const VerifyFilename: Boolean; const KeepOpen: Boolean): TFileStream;',
  531. 'function Round(const E: Extended): Int64;',
  532. 'function Trunc(const E: Extended): Int64;',
  533. 'function MulDiv(const Number, Numerator, Denominator: Integer): Integer;',
  534. 'function StrToColor(const S: String): TColor;',
  535. 'function RPos(const SubStr, S: String): Integer;'
  536. ];
  537. {$IFDEF COMPIL32PROJ}
  538. {$IFDEF DEBUG}
  539. for var ScriptFuncTable in ScriptFuncTables do
  540. CheckIsCleanScriptFuncTable(ScriptFuncTable);
  541. CheckIsCleanScriptFuncTable(DelphiScriptFuncTable);
  542. CheckIsCleanScriptFuncTable(ROPSScriptFuncTable);
  543. {$ENDIF}
  544. {$ENDIF}
  545. end.