[英]What is IViewObject and How is it Used in C#
I'm trying to do a few internet explorer automation tasks and it's requiring me to use IViewObject. 我正在尝试执行一些Internet Explorer自动化任务,这需要我使用IViewObject。 What is IViewObject? 什么是IViewObject? Where can I find it's definition? 在哪里可以找到它的定义?
I've been google-ing and everything I find has a different interface definition for IViewObject. 我一直在谷歌搜索,我发现的一切都有一个IViewObject的不同接口定义。 Different methods or different parameters going into the same methods. 将不同的方法或不同的参数用于相同的方法。
How do I know what interface definition to use with internet explorer? 我如何知道与Internet Explorer一起使用的接口定义?
This is one definition I found on pinvoke.net 这是我在pinvoke.net上找到的一个定义
[GuidAttribute( "0000010d-0000-0000-C000-000000000046" )]
[InterfaceTypeAttribute( ComInterfaceType.InterfaceIsIUnknown )]
[ComImportAttribute()]
public interface IViewObject
{
void Draw( [MarshalAs( UnmanagedType.U4 )] int dwDrawAspect, int lindex, IntPtr pvAspect, DVTARGETDEVICE ptd, IntPtr hdcTargetDev, IntPtr hdcDraw, COMRECT lprcBounds, COMRECT lprcWBounds, IntPtr pfnContinue, int dwContinue );
int GetColorSet( [MarshalAs( UnmanagedType.U4 )] int dwDrawAspect, int lindex, IntPtr pvAspect, DVTARGETDEVICE ptd, IntPtr hicTargetDev, out tagLOGPALETTE ppColorSet );
int Freeze( [MarshalAs( UnmanagedType.U4 )] int dwDrawAspect, int lindex, IntPtr pvAspect, out IntPtr pdwFreeze );
int Unfreeze( [MarshalAs( UnmanagedType.U4 )] int dwFreeze );
int SetAdvise( [MarshalAs( UnmanagedType.U4 )] int aspects, [MarshalAs( UnmanagedType.U4 )] int advf, [MarshalAs( UnmanagedType.Interface )] IAdviseSink pAdvSink );
void GetAdvise( [MarshalAs( UnmanagedType.LPArray )] out int[] paspects, [MarshalAs( UnmanagedType.LPArray )] out int[] advf, [MarshalAs( UnmanagedType.LPArray )] out IAdviseSink[] pAdvSink );
}
I would just try this definition, but I get a few types that are unknown: DVTARGETDEVICE, COMRECT, tagLOGPALETTE. 我将尝试使用此定义,但是会得到一些未知的类型:DVTARGETDEVICE,COMRECT,tagLOGPALETTE。 So my next question is, what assembly needs to be referenced to use these types? 所以我的下一个问题是,使用这些类型需要引用什么程序集?
DVTARGETDEVICE and COMRECT are structures. DVTARGETDEVICE和COMRECT是结构。 You can find their definitions on pinvoke.net. 您可以在pinvoke.net上找到它们的定义。
tagLOGPALETTE is a class. tagLOGPALETTE是一个类。 There is a sample available at http://blogs.msdn.com/vsod/archive/2008/11/01/resizing-the-embedded-ole-objects-using-net.aspx . 在http://blogs.msdn.com/vsod/archive/2008/11/01/resizing-the-embedded-ole-objects-using-net.aspx上有一个示例。
In addition, IViewObject and the three referenced types are all used internally by the .NET Framework. 此外,.NET Framework在内部使用了IViewObject和三个引用的类型。 If you grab yourself a copy of Reflector ( http://www.red-gate.com/products/reflector/ ), you can view existing implementations in System.Windows.Forms.UnsafeNativeMethods. 如果您自己获得了Reflector的副本( http://www.red-gate.com/products/reflector/ ),则可以在System.Windows.Forms.UnsafeNativeMethods中查看现有的实现。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.