Newbie question: COM programming and linking to Windows libraries

Patrick Kristiansen patrick.kristiansen at gmail.com
Wed Mar 11 14:31:33 PDT 2009


Hi

I've been trying out D lately, and I really love it. I use the Tango library at the moment, and I wanted to do some simple COM programming, which I'm also a newbie at, just to get more acquainted with Windows programming in D.

What I want to do is relatively simple I think. I want to use the IActiveDesktop COM interface to change the wallpaper of my desktop. So far I have ported the definition of the interface to D and the different structs used as arguments to the interface's methods. The porting went pretty easily, although I haven't been able to test it yet (I'll return to that in a moment). The standard Windows types (e.g. LPCTSTR, DWORD, etc.) are, as you probably know, defined in tango.sys.win32.Types.

I looked at the samples that is included with the DMD compiler bundle (dclient.d, dserver.d and chello.d) to see COM programming in D is done. Apparently, one of the first things to do is call CoInitialize(...), and this is where my problem arises.

CoInitialize is located in ole32.lib, but in the Tango distribution of DMD, there is no ole32.lib included. I thought, since I have the Windows SDK (x64) installed, that I could just link directly to the ole32.lib included there.

Now, this is probably obvious to some people - but not to me. Why doesn't this work? Why does OPTLINK fail and tell me that the format of the .lib file is wrong? Is it because Digital Mars compilers produce .lib files in a different format? Is it because I have the 64 bit SDK installed, and DMD and optlink only produce and consume 32 bit object files and libraries?

Please enlighten me ;-)

Thanks in advance.

-Patrick


More information about the Digitalmars-d-learn mailing list