asp.net 通过VSTO使屏幕截图内容在阅读邮件时被封锁

bjg7j2ky  于 5个月前  发布在  .NET
关注(0)|答案(2)|浏览(58)

我们有一个VSTO插件,我们需要黑掉打开邮件的电子邮件窗口。如果必须通过SetWindowDisplayAffinity完成,我们如何通过VSTO插件获得SetWindowDisplayAffinity的正确句柄?
我们确实尝试通过进程中获得的句柄来设置WindowDisplayAffinity,但没有效果

nqwrtyyt

nqwrtyyt1#

Inspector Outlook对象强制转换到IOleWindow接口(也适用于Explorer对象),并调用IOleWindow::GetWindow以获取其HWND

anauzrmj

anauzrmj2#

您可以通过将Outlook窗口示例(如Explorer或Inspector)强制转换到IOLEWindow接口并使用IOleWindow::GetWindow方法来检索可用于该函数的窗口句柄,该方法检索参与就地激活的窗口之一(框架,文档,父窗口或就地对象窗口)的句柄。
下面是示例代码,显示了如何在Outlook窗口中使用IOLEWindow界面:

/// <summary>
 /// Implemented and used by containers and objects to obtain window handles 
 /// and manage context-sensitive help.
 /// </summary>
 /// <remarks>
 /// The IOleWindow interface provides methods that allow an application to obtain  
 /// the handle to the various windows that participate in in-place activation, 
 /// and also to enter and exit context-sensitive help mode.
 /// </remarks>
 [ComImport]
 [Guid("00000114-0000-0000-C000-000000000046")]
 [InterfaceType (ComInterfaceType.InterfaceIsIUnknown)]
 public interface IOleWindow
 {
     /// <summary>
     /// Returns the window handle to one of the windows participating in in-place activation 
     /// (frame, document, parent, or in-place object window).
     /// </summary>
     /// <param name="phwnd">Pointer to where to return the window handle.</param>
     void GetWindow (out IntPtr phwnd) ;

     /// <summary>
     /// Determines whether context-sensitive help mode should be entered during an 
     /// in-place activation session.
     /// </summary>
     /// <param name="fEnterMode"><c>true</c> if help mode should be entered; 
     /// <c>false</c> if it should be exited.</param>
     void ContextSensitiveHelp ([In, MarshalAs(UnmanagedType.Bool)] bool fEnterMode) ;
 }

 public void getWindowHandle()
 {
        dynamic activeWindow = Globals.ThisAddIn.Application.ActiveWindow();
        IOleWindow win = activeWindow as IOleWindow;
        IntPtr window = IntPtr.Zero; 
        win.GetWindow(window);
 }

字符串

相关问题