How To ...
     
Implement Reg Free COM






Solutions Schedule WPF - Gantt style drag and drop multi resource scheduling





Resources


Smart Client

Web Demos



Tech Tips


The Dynamics of
Scheduling white paper



Warehouse Shipment Scheduling o
n YouTube
 


.NET Products

Solutions Schedule



Studio Controls


Extractor



COM Products


Solutions Schedule


Studio Controls


Extractor



Frameworks


Warehouse and Shipment Scheduling




Commercial Software

Staff Scheduler Pro



    Free Trials

 
Interest in our COM products is still very strong, which has led to more questions on the deployment side of things. As such I thought we’d delve into an interesting but often overlooked method of deploying ActiveX controls with applications. It’s called RegFree COM. That’s right, as the name implies it removes the need to RegSvr .ocx files or register them during deployment.

This has an impact especially with the Windows 10 UAC and registry lockdowns across networks. The process is pretty straightforward, you build a '.manifest' file for your application that contains all the information needed to call your .ocx files.

Here is the breakdown… you will need an IDE that will compile down to an executable in order to attach the manifest. In our sample below we will simply use the method for including the .manifest file with the application.exe, but there are ways to build the manifest into the actual executable. For more information on that do a Web Search on MT.exe and manifest.

Basically you can point the executable you are running to the OLE control you want to use and specify the GUIDS for the TypeLib and Class in the .manifest file thus eliminating the need to check the registry (you can do a quick web search on RegFree COM for more on the background story).  We'll focus on how you can set one up to use DBI controls. As you are going to need both the typelib ID and class ID you may want to trackdown a copy of OLEVIEW. That little tool shipped back with VisualStudio 6 (I think it may actually go back to 4) but you can find a copy here... https://msdn.microsoft.com/en-us/library/d0kh9f4c.aspx 

So basically let’s start a small sample app for testing purposes... we'll toss ctxList on a form and call our app ctxListTest.exe   Add a couple of node items in the firstdraw event and build your app.  Now let’s copy our ctxList.ocx control to a folder in your app path called bin. We are then going to create a file called ctxListTest.exe.manifest in the same folder as the executable. You can also check out some articles on building the manifests into the executables, here are a couple of command line utilities available from Microsoft that will handle this, but for our example we are going to use the "deploy with executable" method. The XML is going to look like so...


<?xml version="1.0" encoding="utf-8"?>

<assembly xsi:schemaLocation="urn:schemas-microsoft-com:asm.v1 assembly.adaptive.xsd" manifestVersion="1.0" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

  <assemblyIdentity name="ctxList.exe" version="1.0.0.0" type="win32" />

  <file name="bin\ctxList.ocx" asmv2:size="118784">

    <typelib tlbid="{F5A21BA6-2C08-11D5-A85D-0080C8DFC881}" version="6.0" helpdir="" resourceid="0" flags="HASDISKIMAGE"  />

    <comClass clsid="{F5A21BA6-2C08-11D5-A85D-0080C8DFC881}" threadingModel="Apartment" tlbid="{F5A21BA6-2C08-11D5-A85D-0080C8DFC881}" progid="ctxList.ctxListCtrl.6" description="ctxList Control" />

  </file>

</assembly>

Now you can see we have a single <file> tag in our XML, you can have as many as you need to define for your app. Notice this one is for ctxDate, we are going to mod it for use with ctxList by changing the tag properties as follows...

This info is from the actual exe file properties...

-orig-<assemblyIdentity name="ctxList.exe" version="1.0.0.0" type="win32" />

-new-<assemblyIdentity name="ctxListTest.exe" version="1.0.0.0" type="win32" />

Now for the OCX part...

-orig-

  <file name="bin\ctxList.ocx" asmv2:size="118784">

    <typelib tlbid="{F5A21BA6-2C08-11D5-A85D-0080C8DFC881}" version="6.0" helpdir="" resourceid="0" flags="HASDISKIMAGE"  />

    <comClass clsid="{F5A21BA6-2C08-11D5-A85D-0080C8DFC881}" threadingModel="Apartment" tlbid="{F5A21BA6-2C08-11D5-A85D-0080C8DFC881}" progid="ctxDATE.ctxListCtrl.6" description="ctxList Control" />

  </file>

-new-

  <file name="bin\ctxList.ocx" asmv2:size="471040">

    <typelib tlbid="{38EC7E50-6A01-4727-88E7-47788ABD54FE}" version="6.0" helpdir="" resourceid="0" flags="HASDISKIMAGE"  />

    <comClass clsid="{2B447B04-4CDC-4F52-915C-694DDCAD79F4}" threadingModel="Apartment" tlbid="{38EC7E50-6A01-4727-88E7-47788ABD54FE}" progid="ctxLIST.ctxListCtrl.6" description="ctxList Control 6.0" />

  </file>

So your XML text for the ctxList will be...

<?xml version="1.0" encoding="utf-8"?>

<assembly xsi:schemaLocation="urn:schemas-microsoft-com:asm.v1 assembly.adaptive.xsd" manifestVersion="1.0" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<assemblyIdentity name="ctxListTest.exe" version="1.0.0.0" type="win32" />

  <file name="bin\ctxList.ocx" asmv2:size="471040">

    <typelib tlbid="{38EC7E50-6A01-4727-88E7-47788ABD54FE}" version="8.0" helpdir="" resourceid="0" flags="HASDISKIMAGE"  />

    <comClass clsid="{2B447B04-4CDC-4F52-915C-694DDCAD79F4}" threadingModel="Apartment" tlbid="{38EC7E50-6A01-4727-88E7-47788ABD54FE}" progid="ctxLIST.ctxListCtrl.8" description="ctxList Control 8.0" />

  </file>

</assembly>

Reg-Free COM
full view

If you wish to test this on your dev machine, you'll have to regsvr32/u ctxList.ocx  (in your Studio Controls for COM install folder) then if you did everything right your app should run as normal, rename the ctxListTest.exe.manifest to something else and run it and you should get a class unregistered error.

As always from all of us here in support, take are and have a great programming day!

 

      Free Trials
     
       
      all rights reserved  |  copyright © 1996 - 2021   |  Terms of Use
 
      https://www.dbi-tech.com