"hello world"
article in Tech programming

COM development

COM (Component Object Model) development is something that takes time to understand. I spent many hours reading about how COM works and how to program with it. I thought it was fun to create applications that integrate very closely with Word and IE. The ability to abstract methods of execution on multiple machines using IUnknown is great. DCOM and COM were a beast to learn however. There are many levels of abstractions to learn about. All of a sudden we are talking about contracts in IDL, querying for interfaces, registering controls, reference counting, threading apartment models, etc. It all takes time to grok.

COM taught me to program to the interface. One usually wants to abstract out portions of their program to run on different machines or on the same machine across threads. These interfaces can be exposed to scripting languages like VBScript, JScript to allow for easy composition of functionality. COM is powerful and efficient at times. .NET managed code and the CLR have negated the need for much of it however. It was something that was promised as cross platform, without an implementation and looks to be going out the door?!
Microsoft kills more third-party ActiveX controls


A lot of HRESULT codes... - Random Thoughts and Hints on Software Development - Site Home - MSDN Blogs

COM Maintenance

Apparently there were some pretty serious security holes in ATL. Do you know that your ActiveX/COM assets are safe? Make sure to read the literature and patch accordingly!

Microsoft Security Bulletin MS09-035 - Moderate: Vulnerabilities in Visual Studio Active Template Library Could Allow Remote Code Execution (969706)
ATL Security Update July 28 2009, Microsoft announced that ATL was impacted in Security Advisory (973882) and provided updated versions of ATL with the release of security bulletin MS09-035.



You can build COM components from all sorts of languages. MFC, VB, C#, Python, PHP, Perl, etc.
The best way to create native COM controls is to write them using C++ ATL.
The executables are small, fast, and easy to deploy.
You can create and consume COM components from managed code as well.

Some of the things you can do because of COM...


Automate word/excel/access/etc to perform basically any action within the application as well as close access to the object model exposed. Also, have the ability to receive events as the user performs actions.
Create new UI within IE using ActiveX. ActiveX is trusted native code, so you can really do anything your little heart desires.
ISAPI filters for internet information server (MS's webserver).
Extend windows explorer to add additional menu items.
Custom applications of course.


ActiveX does not own it's own MessageLoop

Messages are pushed to it from the container, so one work around is to create a message hook.
The TAB key, arrow keys, and accelerator keys do not work as expected when an ActiveX control is the parent window of a modeless dialog box or of a propertysheet window

Windows Template Library - WTL

When writing native COM controls, I think adding WTL is very important to gain strong UI capabilities. WTL is a set of C++ template libraries which extend the ATL templates with rich UI control. I've written and seen some very cool UI with WTL.
SourceForge.net: Windows Template Library (WTL)
CodeProject: WTL Class for ActiveX Hosting.
Unwound Stack » How does WTL connect HWNDs to C++ objects?
sergiu / wtl-cmake — Bitbucket - CMake find module for the Windows Template Library
sergiu / wtl-helper — Bitbucket - Fixes and improvements for Sergey Solozhentsev's WTL helper
sergiu / wtl-dockwins — Bitbucket - This projects represents a fork of Sergey Klimov's WTL docking windows library. It aims at fixing and imporving the library.


COM future?

Today, there are still somethings that are only done with COM. So until .NET replaces everything. There is still a real need for it.




The comtypes package - The comtypes python package makes it easy to access and implement both custom and dispatch based COM interfaces.

Active Template Library - ATL

CodeProject: ATL/AUX Library. - great article and code.
CodeProject: ATL - the whole ATL section in codeproject is priceless.
daily blah: Practial advising with ATL
BUGFIX: ATL's CWindowImpl crashes when OnFinalMessage contains code to destroy the class instance


COM Eventing

AtlEvnt.exe sample shows how to creates ATL sinks by using the ATL IDispEventImpl and IDispEventSimpleImpl classes
How to sink HTML document events for WebBrowser host - syncs DWebBrowserEvents2 for DocumentComplete and then syncs to the documents HtmlDocumentEvents


com proxy stub dll

used to marshal data across boundaries like process boundaries or apartment boundaries.
COM proxy stub dll and why do you need it - Random Thoughts and Hints on Software Development - Site Home - MSDN Blogs - my.idl -> my_h.h, my_i.c, my_p.c and dlldata.c


signcode without password / signcode don't prompt password

If you are writing certain types of COM controls (IE activex controls), you will need to sign your code with a signing key. To sign you'll use signcode, but signcode doesn't allow you to pass a password argument. Instead, use signtool.exe which comes part of VS2005 and within the (Platform SDK/Windows SDK). If you are using the Windows SDK, when I installed it was in "C:\Program Files\Microsoft SDKs\Windows\v6.1\Bin". It does allow you to specify the private key password on the command line. This is useful for automating a signed build.
Code Signing for Developers
Code Signing - more overview of signing stuff.
Download details: Office 2000 Tool: PVK Digital Certificate Files Importer - includes pvkimprt tool
P4 Tasks » Problems and Solutions installing pvkimprt.exe


Shell programming

Windows® API Code Pack for Microsoft® .NET Framework (v0.85) - Home - interesting, stuff you could only do with COM in managed code! Support for Windows Shell namespace objects, including the new Windows 7 libraries, Known Folders and non file system containers, Windows 7 Explorer Browser Control supporting both WPF and Windows Forms, Support for Shell property system.


BITS - Background Intelligent Transfer Service

daily blah: Background Intelligent Transfer Service


Moserware: Finally Understanding COM After Changing a Light Bulb
Moserware: Using Obscure Windows COM APIs in .NET


Dependency Walker (depends.exe) Home Page - this tool has been invaluable to me. It tells you all the files required for a binary. (ocx,dll,exe,etc)
Jer's One Stop Shop > Home - Silverlight 4 Hack: Use Native/Desktop CLR Without COM Registration
COM for the “I did C++ once a thousand years ago, but only do .NET now” Developer –or– In the Defense of COM « Jer's Hacks
Moserware: Using Obscure Windows COM APIs in .NET


COM in plain C - CodeProject goes to COM in plain C, Part 7 - CodeProject.
Created: 2008-03-28 07:26:41 Modified: 2014-05-17 22:48:04
/root sections/
>peach custard pie
>linux
>windows
>programming
>random tech
>science
>research


moon and stars



My brain

Visible Dave Project


x days to Christmas.
x days to a new year.
Happy Holidays!