In a .NET 3.0 project, I need to make some calls via P/Invoke (specifically to the PrintTicket Provider functions like PTConvertPrintTicketToDevMode() ).
The framework has a managed definition of the COM IStream interface: System.Runtime.InteropServices.ComTypes.IStream
I need this as System.IO.Stream so that I can easily use .NET classes (like XmlDocument) with the output of these imported functions. But I can't see a less painful way of converting this back and forth to System.IO.Stream other than reading and writing data a block of bytes at a time. It seems too kludgey for a task that would seem very common.
Or am I going at this the wrong way?
I have PTConvertPrintTicketToDevMode() imported as:
[DllImport("prntvpt.dll")]
public static extern int
PTConvertPrintTicketToDevMode(IntPtr hProvider,
IStream pPrintTicket,
EDefaultDevmodeType baseDevmodeType,
EPrintTicketScope scope,
IntPtr pcbDevmode,
out IntPtr ppDevmode,
[MarshalAs(UnmanagedType.BStr)]out String pbstrErrorMessage);