To add a dependency for an OCX (Simpdll.dll in this example), a section similar to the section for the control is added to the [AddCode] section of the INF file:
To include the DLL in a separate CAB file, all that is necessary is to change the location from "thiscab" to the URL at which the dependent CAB will be located:
Multiple DLLs can be added to the INF and CAB files above if necessary.
The third way to package dependent DLLs is to refer to the dependent DLL's CAB file using a hook. With this technique, an INF or EXE file in the dependent CAB can be executed on download.
The following section from an .inf file controls the dependent DLL download for MFC controls:
Or, you will need to build a self extracting EXE file using third party tools.
To illustrate, the following is the .inf file used to install the dependent MFC DLLs. You can modify this to install your own DLLs in the same way that the MFC DLLs are installed.
; ========================= Mfc42.inf =========================
; This file will control the download of the MFC 4.2 DLLs
; version signature (same for both NT and Win95) do not remove
; This section specifies that all sources are in the "default"
; Default section to process and copy all files under the section
; mfcdllsx.files and Register DLLs under the section mfcdllsx.register.
; Destination Directories for CopyFiles Sections.
; 11 indicates LDID_SYS - system directory
; ,,,32 - Suppress version conflict dialog and don't overwrite newer
; msvcrt.dll is not self registering
; ====================== Mfc42.inf ======================
Beware, however, that running Regsvr32 on the DLL may have undesirable side effects. When DllRegisterServer is called, it makes appropriate registry entries pointing to the DLL location on the machine. For example, typing the following in an MS-DOS prompt, for test purposes, can cause problems:
copy mfc42.dll C:\Test
run "D:\msdev\bin\REGSVR32.EXE C:\Test\mfc42.dll"
Installing a DLL with a hook and a self extracting EXE is useful for the following reason: If a DLL that needs to be upgraded is already loaded in memory, the download will fail. This is a known problem, which has been fixed in Internet Explorer version 4.0. Internet Explorer 4.0 will suggest a reboot and load the new DLL during the reboot.
For more information, see the following Webcast:
รหัสบทความ: 165075 - การตรวจสอบครั้งสุดท้าย: 28 ก.ย. 2011 - ฉบับแก้ไข: 1