To break free from dll-hell you can use manifests to spesify that your application should use local dll's instead of system dll's.
As an added bonus you will not have to register the dll's with regsvr32 in order to use them. Nice if end user is not local admin.
In order to redirect exe to use local dll's all you need is a manifest file pr dll and a corresponding manifest file for the exe.
You could compile the exe-manifest file into the exe, but it's not required.
The most tricky part is to get the dll-manifest and the exe-manifest to work together.
Create dll-manifests
I'll recomend generating the dll-manifests using microsofts mt.exe (on Win2k8 R2 i found it in C:\Program Files\Microsoft\SDKs\Windows\v6.1\Bin\mt.exe)
The command line for generating dll-manifest is: mt.exe -tlb:example.dll -dll:example.dll -out:example.dll.manifest
Open the generated manifest file and clean it up by adding linebreak and indention.
For our use we had no use of the comInterfaceExternalProxyStub, so I deleted those entries. But leaving them in would do no harm I guess.
Create exe-manifest
Best illustrated with an example.
Here is our manifest for an app named Navi.exe that uses three dll's:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity type="win32" name="Navi.exe" version="1.0.0.0" />
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="ChilkatRsa.dll" version="9.3.1.0"/>
</dependentAssembly>
</dependency>
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="ChilkatCrypt2.dll" version="9.3.0.0"/>
</dependentAssembly>
</dependency>
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="ChilkatCert.dll" version="9.3.0.0"/>
</dependentAssembly>
</dependency>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!--The ID below indicates application support for Windows Vista -->
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
<!--The ID below indicates application support for Windows 7 -->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
</application>
</compatibility>
</assembly>
You will need to replace application/dll name and version.
The last section: compability says that our application is compatible with Vista and Win7
To run your application using local dll's, the exe, dll's and it's corresponding manifests needs to be in the same folder.
If you are writing your application in delphi you could add the exe-manifest in the exe by creating a resource file: appname.RC
With the following line: 1 24 "appname.exe.manifest"
And then compile the RC: brcc32 appname.RC
You should then have a appname.RES that you would have to include in your project. I guess you already have a "{$R *.res}" line in your dpr-file. If so it would be included in your exe, the next time you compile your project.
I sometimes get conflict with the apps icon that delphi tries to put in the same res-file. So if your app is missing the icon after adding the manifest. Try adding it to the project again, I have not found out when it gives me a conflict and when it doesn't...
Ove B-) |