September 09, 2012 Re: Recipe and best practice for accessing COM | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sean Cavanaugh | On 9/9/2012 7:57 AM, Sean Cavanaugh wrote:
> On 9/9/2012 7:30 AM, newToCOM wrote:
>
> I've been super busy at work so haven't had much time to respond to this
> thread.
>
I also have a D version of something resembling ATL's CComPtr which I am finally happy enough with to share, that I could post when i get home later tonight.
The class is a good argument for keeping the rather esoteric opDot operator, since alias this is extremely dangerous for smart pointer structs in D.
|
September 09, 2012 Re: Recipe and best practice for accessing COM | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sean Cavanaugh | > In this example the pID2D1Factory is a void*, so it will need a cast to the proper type with a cast(ID2D1Factory) soemtime after the create call;
>
> Since this particular API takes an out void* (since it is capable of creating multiple unrelated types), it would need to look something like this:
>
> HRESULT hr = D2D1CreateFactory(
> D2D1_FACTORY_TYPE.SINGLE_THREADED,
> pIID_ID2D1Factory,
> pfactoryOptions,
> pID2D1Factory);
>
> if (SUCCEEDED(hr))
> {
> assert(pID2D1Factory !is null);
> ID2D1Factory factory = cast(ID2D1Factory)pID2D1Factory;
> factory.GetDesktopDpi(dpiX, dpiY);
> }
>
>
> I've been super busy at work so haven't had much time to respond to this thread.
>
>
> Technically the API's fourth argument could be rewritten to be an 'out IUnknown', but then you are stuck calling QueryInterface, and back to having the exact same problem with the QueryInterface method.
Thanks a lot! That solved my issue.
|
September 09, 2012 Re: Recipe and best practice for accessing COM | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sean Cavanaugh | > I also have a D version of something resembling ATL's CComPtr which I am finally happy enough with to share, that I could post when i get home later tonight.
>
> The class is a good argument for keeping the rather esoteric opDot operator, since alias this is extremely dangerous for smart pointer structs in D.
That would be great!
|
Copyright © 1999-2021 by the D Language Foundation