Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.

ID: 30019, 64/32bit COM interop

by Ray Vecchio Email: Anonymous

Here an easy way to use 64bit COM classes in 32bit applications and vice a versa...
Download Details
FTP  download also available
CDN Login Required to Download. (You will be redirected to the login page if you click on the Download Link)
To download this, you must have registered:
A free membership

For Delphi, Version 12.0  to 15.0 98 downloads
Copyright: Open Source or other

Size: 67,102 bytes
Updated on Fri, 10 Oct 2014 13:17:12 GMT
Originally uploaded on Fri, 10 Oct 2014 13:17:03 GMT
SHA1 Hash: 0B5EAA1B2EB12B971CB40D039E3C28E916A02D67
MD5 Hash: 0E5C80A958222B6346E9B3B908403B8B

    Explore the files in this upload

I have created a simple unit to do the leg work.
1) Create your COM automation objects as normal.
2) add the unit "COMDLLSurrogateUnit"
3) then modify the name of the TAutoObjectFactory to TAutoObjectDLLSurrogateFactory

Here is what the changes look like:
unit ImplTest64bitCOMUnit;


ComObj, ActiveX, COM64BitTest_TLB, StdVcl;

TTest64BitCOM = class(TAutoObject, ITest64BitCOM)
procedure Testing; safecall;



uses ComServ, Dialogs, COMDLLSurrogateUnit; // heavy lifting unit

procedure TTest64BitCOM.Testing;

//***NOTE*** the new Automation class factory
TAutoObjectDLLSurrogateFactory.Create(ComServer, TTest64BitCOM, Class_Test64BitCOM,
ciMultiInstance, tmApartment);

How it works...
Essentially what the unit does it the follow, say you want to use a 32-bit application to call a 64bit COM class:
1) Create the 64bit COM class, make it an Automation object this should make life easier.
2) build and register the 64 bit COM DLL
3) use regedit and go to
HKey_Classes_Root\CLSID\<your GUID>
4) Add a new string value called "AppID" and give it the same value as <your GUID>
5) now go to HKey_Classes_Root\Wow6432Node\AppID\
6) add a new key with the same GUID as the CLSID i.e. <your GUID>
7) under the new key create a string value called "DllSurrogate" (without the quotes) and leave the data empty
8) the registry system should have mirrored the AppID in HKey_Classes_Root\AppID\<your GUID>
9) in the IDE in your 32bit application just link in the XXX_TLB.pas of the 64-bit COM class
10) and use COM object as normal.

To use the COM classes in components in the IDE
1) register and set up your 64-bit COM DLL as I previously described
2) you need to use the tlibimp from the \Bin64 directory to generate the component wrapping code.
3) create a package and add the generated file from 2) to the package and install the package.

All of the information on how to accomplish this is found here:

   Latest Comments  View All Add New

Move mouse over comment to see the full text

Could not retrieve comments. Please try again later.

Server Response from: ETNACDC04