Accessing COM Objects

Mike Parker via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Jun 12 18:52:12 PDT 2016


On Monday, 13 June 2016 at 01:22:33 UTC, Incognito wrote:

> I can do this stuff in C# by simply dragging and dropping a dll 
> into the references and it works fine but is a bit slow. I was 
> hoping I could speed things up using D but it seems like COM 
> isn't really supported, despite what several references say.

Com *is* supported in D. I think it's better to work with 
interfaces rather than classes like the Wiki example:

interface MyCOMType : IUknown {}

Then when you get a pointer from CoCreateInstance or whatever, 
you cast it to the interface type and away you go.

In your code, your problem is that CoCreateInstance is failing, 
not that D doesn't support COM. It will help you to find out what 
the actual value of 'hr' is. Possible values are listed at [1].

[1] 
https://msdn.microsoft.com/en-us/library/windows/desktop/ms686615(v=vs.85).aspx


More information about the Digitalmars-d-learn mailing list