Shared.ScriptFunc.pas 31 KB

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