Shared.ScriptFunc.pas 32 KB

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