Sfoglia il codice sorgente

Update [Code] RegisterServer/RegisterTypeLibrary/UnregisterTypeLibrary to supply current-process-bit filenames. Removes the need for the PathExpand calls.

Also update docs.
Martijn Laan 3 settimane fa
parent
commit
7ea606003a

+ 7 - 2
ISHelp/isetup.xml

@@ -1713,9 +1713,11 @@ ExternalSize: 1_048_576; Flags: external
 <flaglist>
 <flag name="32bit">
 <p>Causes the <tt>{sys}</tt> constant to map to the 32-bit System directory when used in the <tt>Source</tt> and <tt>DestDir</tt> parameters, the <tt>regserver</tt> and <tt>regtypelib</tt> flags to treat the file as 32-bit, and the <tt>sharedfile</tt> flag to update the 32-bit SharedDLLs registry key. This is the default behavior in <link topic="32vs64bitinstalls">32-bit install mode</link>.</p>
+<p>Combining <tt>32bit</tt> and <tt>regtypelib</tt> requires a <link topic="64bit">32-bit installer</link>.</p>
 </flag>
 <flag name="64bit">
 <p>Causes the <tt>{sys}</tt> constant to map to the 64-bit System directory when used in the <tt>Source</tt> and <tt>DestDir</tt> parameters, the <tt>regserver</tt> and <tt>regtypelib</tt> flags to treat the file as 64-bit, and the <tt>sharedfile</tt> flag to update the 64-bit SharedDLLs registry key. This is the default behavior in <link topic="32vs64bitinstalls">64-bit install mode</link>.</p>
+<p>Combining <tt>64bit</tt> and <tt>regtypelib</tt> requires a <link topic="64bit">64-bit installer</link>.</p>
 </flag>
 <flag name="allowunsafefiles">
 <p>Disables the compiler's automatic checking for <link topic="unsafefiles">unsafe files</link>. It is strongly recommended that you DO NOT use this flag, unless you are absolutely sure you know what you're doing.</p>
@@ -1838,6 +1840,7 @@ Instructs Setup to proceed to comparing time stamps (last write/modified time) i
 <flag name="regtypelib">
 <p>Register the type library (.tlb). The uninstaller will unregister the type library (unless the flag <tt>uninsneveruninstall</tt> is specified). As with the <tt>regserver</tt> flag, when used in combination with <tt>sharedfile</tt>, the file will only be unregistered by the uninstaller when the reference count reaches zero.</p>
 <p>In <link topic="32vs64bitinstalls">64-bit install mode</link> running on an x64-compatible edition of Windows, the type library will be registered inside a 64-bit process. You can override this by specifying the <tt>32bit</tt> flag.</p>
+<p>64-bit type libraries can only be (un)registered by <link topic="64bit">64-bit installers</link>, and 32-bit type libraries only by 32-bit installers.</p>
 <p>See the <i>Remarks</i> at the bottom of this topic for more information.</p>
 </flag>
 <flag name="replacesameversion">
@@ -3010,6 +3013,8 @@ Name: bosskey; KeyFile: "boss.ispublickey"
   <li>You cannot load 32-bit DLLs in 64-bit installers because Windows does not allow 64-bit processes to load 32-bit DLLs (and vice versa). However, you can always launch both 32-bit and 64-bit EXEs using the <tt>Exec</tt> function or the [Run] section.</li>
   </ul>
 </li>
+<li>64-bit type libraries (.tlb) can only be (un)registered by 64-bit installers, and 32-bit type libraries only by 32-bit installers.<br/>
+    Support for (un)registering 64-bit type libraries from a 32-bit installer has been dropped.</li>
 <li><tt>{sysnative}</tt> is not accessible to 64-bit installers or any other 64-bit applications, so use its value only to, for example, pass it to a 32-bit application.</li>
 </ul>
 
@@ -3294,7 +3299,7 @@ Filename: "{win}\MYPROG.INI"; Section: "InstallSettings"; Key: "InstallPath"; St
 <li>The <tt>{reg:...}</tt> constant reads the 32-bit view by default.</li>
 <li>The <tt>Reg*</tt> [Code] support functions access the 32-bit view by default.</li>
 <li>The <tt>useapppaths</tt> flag of the [Icons] section reads the "App Paths" key in the 32-bit view of the registry.</li>
-<li>The <tt>regserver</tt> and <tt>regtypelib</tt> flags of the [Files] section load and register files inside a 32-bit process by default.</li>
+<li>The <tt>regserver</tt> and <tt>regtypelib</tt> flags of the [Files] section load and register files inside a 32-bit process by default. Latter requires a <link topic="64bit">32-bit installer</link>.</li>
 <li>The <tt>sharedfile</tt> flag of the [Files] section updates the "SharedDLLs" key in the 32-bit view of the registry by default.</li>
 <li>The Uninstall key is created in the 32-bit view of the registry.</li>
 </ul>
@@ -3311,7 +3316,7 @@ Filename: "{win}\MYPROG.INI"; Section: "InstallSettings"; Key: "InstallPath"; St
 <li>The <tt>{reg:...}</tt> constant reads the 64-bit view by default.</li>
 <li>The <tt>Reg*</tt> [Code] support functions access the 64-bit view by default.</li>
 <li>The <tt>useapppaths</tt> flag of the [Icons] section reads the "App Paths" key in the 64-bit view of the registry.</li>
-<li>The <tt>regserver</tt> and <tt>regtypelib</tt> flags of the [Files] section load and register files inside a 64-bit process by default.</li>
+<li>The <tt>regserver</tt> and <tt>regtypelib</tt> flags of the [Files] section load and register files inside a 64-bit process by default. Latter requires a <link topic="64bit">64-bit installer</link>.</li>
 <li>The <tt>sharedfile</tt> flag of the [Files] section updates the "SharedDLLs" key in the 64-bit view of the registry by default.</li>
 <li>The Uninstall key is created in the 64-bit view of the registry.</li>
 </ul>

+ 8 - 2
ISHelp/isxfunc.xml

@@ -2315,6 +2315,7 @@ end;</pre></example>
         <name>RegisterServer</name>
         <prototype>procedure RegisterServer(const Is64Bit: Boolean; const Filename: String; const FailCriticalErrors: Boolean);</prototype>
         <description><p>Registers the DLL/OCX with the specified filename. If Is64Bit is True, the DLL/OCX will be loaded as a 64-bit image and registered in a 64-bit process. If FailCriticalErrors is True, the system will not display any critical-error-handler message boxes. Raises an exception if not successful.</p></description>
+        <remarks><p>The Is64Bit parameter is also used for an automatic call to <link topic="isxfunc_ApplyPathRedirRulesForCurrentProcess">ApplyPathRedirRulesForCurrentProcess</link>.</p></remarks>
         <example><pre>begin
   // Register hhctrl.ocx located in the System directory.
   RegisterServer(Is64BitInstallMode, ExpandConstant('{sys}\hhctrl.ocx'), False);
@@ -2325,11 +2326,14 @@ end;</pre>
         <name>UnregisterServer</name>
         <prototype>function UnregisterServer(const Is64Bit: Boolean; const Filename: String; const FailCriticalErrors: Boolean): Boolean;</prototype>
         <description><p>Unregisters the DLL/OCX with the specified filename. If Is64Bit is True, the DLL/OCX will be loaded as a 64-bit image and unregistered in a 64-bit process. If FailCriticalErrors is True, the system will not display any critical-error-handler message boxes. Returns True if successful, False otherwise.</p></description>
+        <remarks><p>The Is64Bit parameter is also used for an automatic call to <link topic="isxfunc_ApplyPathRedirRulesForCurrentProcess">ApplyPathRedirRulesForCurrentProcess</link>.</p></remarks>
       </function>
       <function>
         <name>RegisterTypeLibrary</name>
         <prototype>procedure RegisterTypeLibrary(const Is64Bit: Boolean; const Filename: String);</prototype>
-        <description><p>Registers the type library with the specified filename. If Is64Bit is True, the type library will be registered in a 64-bit process. Raises an exception if not successful.</p></description>
+        <description><p>Registers the type library (.tlb) with the specified filename. If Is64Bit is True, the type library will be registered in a 64-bit process. Raises an exception if not successful.</p></description>
+        <remarks><p>If Is64Bit is True then a <link topic="64bit">64-bit installer</link> must be used. Otherwise, a 32-bit installer must be used.</p>
+<p>The Is64Bit parameter is also used for an automatic call to <link topic="isxfunc_ApplyPathRedirRulesForCurrentProcess">ApplyPathRedirRulesForCurrentProcess</link>.</p></remarks>
         <example><pre>begin
   // Register stdole2.tlb located in the System directory.
   RegisterTypeLibrary(Is64BitInstallMode, ExpandConstant('{sys}\stdole2.tlb'));
@@ -2339,7 +2343,9 @@ end;</pre>
       <function>
         <name>UnregisterTypeLibrary</name>
         <prototype>function UnregisterTypeLibrary(const Is64Bit: Boolean; const Filename: String): Boolean</prototype>
-        <description><p>Unregisters the type library with the specified filename. If Is64Bit is True, the type library will be unregistered in a 64-bit process. Returns True if successful, False otherwise.</p></description>
+        <description><p>Unregisters the type library (.tlb) with the specified filename. If Is64Bit is True, the type library will be unregistered in a 64-bit process. Returns True if successful, False otherwise.</p></description>
+        <remarks><p>If Is64Bit is True then a <link topic="64bit">64-bit installer</link> must be used. Otherwise, a 32-bit installer must be used.</p>
+<p>The Is64Bit parameter is also used for an automatic call to <link topic="isxfunc_ApplyPathRedirRulesForCurrentProcess">ApplyPathRedirRulesForCurrentProcess</link>.</p></remarks>
       </function>
       <function>
         <name>IncrementSharedCount</name>

+ 4 - 8
Projects/Src/Setup.InstFunc.Ole.pas

@@ -2,7 +2,7 @@ unit Setup.InstFunc.Ole;
 
 {
   Inno Setup
-  Copyright (C) 1997-2025 Jordan Russell
+  Copyright (C) 1997-2026 Jordan Russell
   Portions by Martijn Laan
   For conditions of distribution and use, see LICENSE.TXT.
 
@@ -201,15 +201,13 @@ end;
 
 procedure RegisterTypeLibrary(const Filename: String);
 var
-  ExpandedFilename: String;
   OleResult: HRESULT;
   TypeLib: ITypeLib;
 begin
-  ExpandedFilename := PathExpand(Filename);
-  OleResult := LoadTypeLib(PChar(ExpandedFilename), TypeLib);
+  OleResult := LoadTypeLib(PChar(Filename), TypeLib);
   if OleResult <> S_OK then
     RaiseOleError('LoadTypeLib', OleResult);
-  OleResult := RegisterTypeLib(TypeLib, PChar(ExpandedFilename), nil);
+  OleResult := RegisterTypeLib(TypeLib, PChar(Filename), nil);
   if OleResult <> S_OK then
     RaiseOleError('RegisterTypeLib', OleResult);
 end;
@@ -220,7 +218,6 @@ type
     lcid: TLCID; syskind: TSysKind): HResult; stdcall;
 var
   UnRegTlbProc: TUnRegTlbProc;
-  ExpandedFilename: String;
   OleResult: HRESULT;
   TypeLib: ITypeLib;
   LibAttr: PTLibAttr;
@@ -231,8 +228,7 @@ begin
     'UnRegisterTypeLib');
   if @UnRegTlbProc = nil then
     Win32ErrorMsg('GetProcAddress');
-  ExpandedFilename := PathExpand(Filename);
-  OleResult := LoadTypeLib(PChar(ExpandedFilename), TypeLib);
+  OleResult := LoadTypeLib(PChar(Filename), TypeLib);
   if OleResult <> S_OK then
     RaiseOleError('LoadTypeLib', OleResult);
   OleResult := TypeLib.GetLibAttr(LibAttr);

+ 12 - 8
Projects/Src/Setup.ScriptFunc.pas

@@ -1144,12 +1144,14 @@ var
     end);
     RegisterScriptFunc('REGISTERSERVER', procedure(const Caller: TPSExec; const OrgName: AnsiString; const Stack: TPSStack; const PStart: Integer)
     begin
-      RegisterServer(False, Stack.GetBool(PStart), Stack.GetString(PStart-1), Stack.GetBool(PStart-2));
+      const Is64Bit = Stack.GetBool(PStart);
+      RegisterServer(False, Is64Bit, ApplyPathRedirRules(Is64Bit, Stack.GetString(PStart-1)), Stack.GetBool(PStart-2));
     end);
     RegisterScriptFunc('UNREGISTERSERVER', procedure(const Caller: TPSExec; const OrgName: AnsiString; const Stack: TPSStack; const PStart: Integer)
     begin
       try
-        RegisterServer(True, Stack.GetBool(PStart-1), Stack.GetString(PStart-2), Stack.GetBool(PStart-3));
+        const Is64Bit = Stack.GetBool(PStart-1);
+        RegisterServer(True, Is64Bit, ApplyPathRedirRules(Is64Bit, Stack.GetString(PStart-2)), Stack.GetBool(PStart-3));
         Stack.SetBool(PStart, True);
       except
         Stack.SetBool(PStart, False);
@@ -1181,26 +1183,28 @@ var
     end);
     RegisterScriptFunc('REGISTERTYPELIBRARY', procedure(const Caller: TPSExec; const OrgName: AnsiString; const Stack: TPSStack; const PStart: Integer)
     begin
+      const Is64Bit = Stack.GetBool(PStart);
       {$IFDEF WIN64}
-      if not Stack.GetBool(PStart) then
+      if not Is64Bit then
         InternalError('Cannot register 32-bit type libraries on this version of Setup');
       {$ELSE}
-      if Stack.GetBool(PStart) then
+      if Is64Bit then
         InternalError('Cannot register 64-bit type libraries on this version of Setup');
       {$ENDIF}
-      RegisterTypeLibrary(Stack.GetString(PStart-1));
+      RegisterTypeLibrary(ApplyPathRedirRules(Is64Bit, Stack.GetString(PStart-1)));
     end);
     RegisterScriptFunc('UNREGISTERTYPELIBRARY', procedure(const Caller: TPSExec; const OrgName: AnsiString; const Stack: TPSStack; const PStart: Integer)
     begin
+      const Is64Bit = Stack.GetBool(PStart-1);
       {$IFDEF WIN64}
-      if not Stack.GetBool(PStart-1) then
+      if not Is64Bit then
         InternalError('Cannot unregister 32-bit type libraries on this version of Setup');
       {$ELSE}
-      if Stack.GetBool(PStart-1) then
+      if Is64Bit then
         InternalError('Cannot unregister 64-bit type libraries on this version of Setup');
       {$ENDIF}
       try
-        UnregisterTypeLibrary(Stack.GetString(PStart-2));
+        UnregisterTypeLibrary(ApplyPathRedirRules(Is64Bit, Stack.GetString(PStart-2)));
         Stack.SetBool(PStart, True);
       except
         Stack.SetBool(PStart, False);

+ 3 - 0
whatsnew.htm

@@ -78,6 +78,9 @@ For conditions of distribution and use, see <a href="files/is/license.txt">LICEN
     <li>You cannot load 32-bit DLLs in 64-bit installers because Windows does not allow 64-bit processes to load 32-bit DLLs (and vice versa). However, you can always launch both 32-bit and 64-bit EXEs using the <tt>Exec</tt> function or the <tt>[Run]</tt> section.</li>
   </ul>
   </li>
+  <li>64-bit type libraries (.tlb) can now only be (un)registered by 64-bit installers, and 32-bit type libraries only by 32-bit installers.<br/>
+      Support for (un)registering 64-bit type libraries from a 32-bit installer has been dropped.</li>
+  <li><tt>{sysnative}</tt> is not accessible to 64-bit installers or any other 64-bit applications, so use its value only to, for example, pass it to a 32-bit application.</li>
 </ul>
 
 <p>Related changes made in both editions:</p>