문제

Currently developing an Outlook add-in with Add-in Express, I have to revert to some pure MAPI functions for reading MAPI properties.

Having this P/Invoke wrapper to the HrGetOneProp function:

[DllImport(@"MAPI32.DLL")]
static extern int HrGetOneProp(IntPtr pmp, uint ulPropTag, out IntPtr ppProp);

I'm trying to pass an Outlook attachment object of type IMAPIProp as the first parameter to the function.

what I'm currently failing in is how to "convert" that object to an IntPtr so that I can pass it as the first parameter to the function. I've tried to use Marshal.StructureToPtr but obviously this failed with an exception, since I am not passing a structure but rather just a reference to an unmanaged COM object.

So my question is:

How to successfully call the HrGetOneProp method with passing a COM object?

도움이 되었습니까?

해결책

다른 팁

I believe that any of Marshal.GetComInterfaceForObject, Marshal.GetIUnknownForObject or Marshal.GetIDispatchForObject should work

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top