Accessing COM Objects

Incognito via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Jun 12 19:08:22 PDT 2016


On Monday, 13 June 2016 at 01:52:12 UTC, Mike Parker wrote:
> 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

What interface are you talking about? How can I cast to something 
I don't have? I do not have a photoshop COM interface. Are you 
saying that if CoCreateInstance worked that I can then use the 
iid or pUnk to access the COM? Do I get the members by trial and 
error? pUnk.width? Even if CoCreateInstance passed, what do I do 
next?




More information about the Digitalmars-d-learn mailing list