Я пытаюсь определить интерфейс COM-объекта, вызывая метод Marshal.QueryInterface.
[DllImport("ole32.dll")]
static extern int CLSIDFromProgID([MarshalAs(UnmanagedType.LPWStr)] string lpszProgID, out Guid pclsid);
public WordFileExtracter(string filename, string contentPrefix, int startAttachmentNumber)
{
var wordApp = new Word.Application();
object confirmConversions = false;
object readOnly = true;
object missing = Type.Missing;
// Opening the Word document
this.document = wordApp.Documents.Open(
ref fn, ref confirmConversions, ref readOnly, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing, ref missing);
foreach (Microsoft.Office.Interop.Word.InlineShape inlineShape in this.document.InlineShapes)
{
if (inlineShape.OLEFormat.ProgID != null)
{
switch (inlineShape.OLEFormat.ProgID)
{
case "AcroExch.Document.7":
Guid myGuid = new Guid();
IntPtr pInterface;
// ERROR! Argument '2': cannot convert
// from 'int' to 'ref System.Guid'
Marshal.QueryInterface(IntPtr.Zero, CLSIDFromProgID("AcroExch.Document.7", out myGuid), out pInterface);
// If for example it implements the
// IPersistStorage interface, then I
// cast to this type
IPersistStorage persist = (IPersistStorage)inlineShape.OLEFormat.Object as IPersistStorage;
У меня нет опыта взаимодействия с Interop.При вызове Marshal.QueryInterface он жалуется на параметр «out myGuid».Что я делаю неправильно?