smourier / DirectN

Direct interop Code for .NET Framework, .NET Core and .NET 5+ : DXGI, WIC, DirectX 9 to 12, Direct2D, Direct Write, Direct Composition, Media Foundation, WASAPI, CodecAPI, GDI, Spatial Audio, DVD, Windows Media Player, UWP DXInterop, WinUI3, etc.
MIT License
311 stars 28 forks source link

Missing `PrintDocumentPackageTargetFactory` class #51

Closed d2phap closed 6 months ago

d2phap commented 6 months ago

Hi @smourier,

I'm playing with Direct2D print control, I cannot find PrintDocumentPackageTargetFactory class in DirectN. Can you please add it? Thank you!

smourier commented 6 months ago

Hi,

It's already defined here https://github.com/smourier/DirectN/blob/master/DirectN/DirectN/Generated/IPrintDocumentPackageTargetFactory.cs

d2phap commented 6 months ago

Oh, I try to create new instance of PrintDocumentPackageTargetFactory with the below code, but it cannot find its definition. I'm following this sample code

Or this is not the correct way?

var fac = new ComObject<IPrintDocumentPackageTargetFactory>(
  (IPrintDocumentPackageTargetFactory)new PrintDocumentPackageTargetFactory()
);
smourier commented 6 months ago

PrintDocumentPackageTargetFactory is a native (C/C++) type that is just used to define a CLSID which value is 348ef17d-6c81-4982-92b4-ee188a43867a defined in %ProgramFiles(x86)%\Windows Kits\10\Include\10.0.22621.0\um\DocumentTarget.h as given by https://www.magnumdb.com/search?q=PrintDocumentPackageTargetFactory

So to get a reference to the IPrintDocumentPackageTargetFactory COM interface, you can use a code similar to this:

var PrintDocumentPackageTargetFactory = new Guid("348ef17d-6c81-4982-92b4-ee188a43867a");
var type = Type.GetTypeFromCLSID(PrintDocumentPackageTargetFactory);
var factory = (IPrintDocumentPackageTargetFactory)Activator.CreateInstance(type);
d2phap commented 6 months ago

Thanks a lot!