What's involved in developing COM objects?

Discuss other programming languages besides AutoHotkey
Miguel7
Posts: 186
Joined: 08 Sep 2014, 07:06

What's involved in developing COM objects?

23 Nov 2014, 01:15

Hi guys,

I've been trying to use some non-standard DLLs in my scripts via DllCall, but I've found there are way too many factors that can throw things off. Part of this has been due to differences between AHK and C++ (or whatever other language the DLLs are written in); for example, in many cases I would get an ErrorLevel of A8 (a difference in the number of bits in the variable being passed as a parameter). Other examples of this are when the DLL takes an object, or an int that's part of an enumeration (and I don't have the actual values of the enum), or some other type that doesn't exist in AHK.

But then I found out one of these DLLs had a COM interface. Next thing I knew, I had created an AHK class that used every single function of the DLL. So it got me thinking, what exactly is needed to create a COM object? From what I've read, the goal of COM was to be language-independent (which is probably why it's so easy to use in AHK, lol), but what language(s) are they written in? What are the requirements for an object to be a COM object? I've tried to google this, but because every other site on earth ends in ".com" it returned a lot of unrelated stuff. So if any of you have done it before, I'd sure like to know. :)
User avatar
maul-esel
Posts: 1
Joined: 22 Nov 2014, 13:52
Contact:

Re: What's involved in developing COM objects?

28 Nov 2014, 17:08

I'm not really an expert, but here's what I know:
  • The calling of COM object methods is realized with a standard memory layout, so you can theoretically do some memory navigation and grab the function pointers, or, to create a COM object, put them there.
  • I once tried to put that to use to expose a COM object developed in AHK - you have the AHK script (COM server) running, and other scripts / C# code can access it. Turns out AHK might just be a little too slow for that (it worked sometimes, but most of the time the scripts crashed).
  • So, if you do the memory stuff by hand and you're fast enough, many languages can probably expose COM.
  • Now, that is in no way practical. Some higher-level programming languages of course can do this stuff for you. I can't tell about C++, but in C# most of it is done with a few attributes (e.g. http://msdn.microsoft.com/en-us/library ... 71%29.aspx)
Miguel7
Posts: 186
Joined: 08 Sep 2014, 07:06

Re: What's involved in developing COM objects?

05 Dec 2014, 17:18

Hey, thanks for the link! I'll definitely have to check it out. I wasn't thinking about developing a COM object in AHK, but kudos for almost getting there! I was kinda thinking the other way around: developing a COM object in some other language that could then be used by AHK. But I don't know enough C++ (yet), but I do know C#, so I was hoping for something like this. At first glance this looks like one heck of a start! :)
Bruttosozialprodukt
Posts: 463
Joined: 24 Jan 2014, 22:28

Re: What's involved in developing COM objects?

05 Dec 2014, 17:59

I once looked this up and it turned out to be extremely complex and complicated...
I guess MS has documented it pretty well, but it really is a lot to read:
http://msdn.microsoft.com/en-us/library ... 85%29.aspx

Return to “Other Programming Languages”

Who is online

Users browsing this forum: No registered users and 11 guests