What is the ($Foo)PS project in my $Foo ATL solution for?

COM supports making interface method calls across two different threads, two different processes or two different machines. This is called marshaling. Two different threads is the most common case, a COM server is often not thread-safe. COM implements thread-safety for such single-threaded coclasses by marshaling the call from the ‘wrong’ thread to the thread that … Read more

RegSvr32 exit codes documentation?

The exit codes are not documented. The documentation is here: https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/regsvr32 However, the source code for a version REGSVR32.EXE is shipped with Visual Studio 2008. This gives its version as 4.0.0, so is not the same as the one shipped with windows, which reports version 6. http://msdn.microsoft.com/en-us/library/ms177531(v=vs.90).aspx A quick look shows these: #define FAIL_ARGS 1 … Read more

How do I properly instantiate 32-bit COM objects in classic ASP after installing Windows Update KB4340558?

We were affected with multiple customers too. I ruled out invalid strong-name signing of our assemblies, since the .NET Assemblies from the Framework itself were affected by that access-denied error too. Finally I managed to solve the issue by configuration. Apparently the authenticating identity of the website has now to match the identity of the … Read more

How to call a complex COM method from PowerShell?

This problem did interest me, so I did some real digging and I have found a solution (though I have only tested on some simple cases)! Concept The key solution is using [System.Type]::InvokeMember which allows you to pass parameter names in one of its overloads. Here is the basic concept. $Object.GetType().InvokeMember($Method, [System.Reflection.BindingFlags]::InvokeMethod, $null, ## Binder … Read more

COM, COM+, DCOM, where to start?

If you are serious about learning COM, Don Box’s “Essential COM” is definitely an absolute “must read”. COM can be confusing and in my humble opinion Don Box is one of the few people who actually “got it”. The example code in “Essential COM” is in C++. You won’t find many books that support COM … Read more

Exposing .NET events to COM?

The key concept in .NET code is to define event(s) as method(s) on a separate interface and connect it to the class via [ComSourceInterfacesAttribute]. In the example this is done with this code [ComSourceInterfaces(typeof(IEvents))] where IEvents interface defines the event(s) which should be handled on COM client. Note to event naming: Event names defined in … Read more

Use OCX without registering it

Yes, this can be done. You must assume your application will only be deployed on Windows XP (or Windows Server 2003) or later, and then you can use what is called ‘registration free COM’ to make this happen. Essentially what you do is create a manifest file for the ActiveX control DLL so the Windows … Read more

Using Component Object Model (COM) on non-Microsoft platforms

Answering myself but I managed to find the perfect library for OLE/COM calling in non-Microsoft compilers : disphelper. (it’s available from sourceforge.net under a permissive BSD license). It works both in C and C++ (and thus any other language with C bindings as well). It uses a printf/scanf-like format string syntax. (You pass whatever you … Read more