我想在 C# 中获取 Outlook 事件窗口句柄 (hwnd)。我想将此用于 SendMessage() 方法,该方法将 hwnd 作为第一个参数。 Outlook 已打开且未最小化。尝试这样做.. 动态 winHwnd= Globals.ThisAddIn.Application.ActiveWindow(); 由于类型不匹配而不起作用。即使我转换它也不起作用。有人可以建议我得到这个处理程序..
最佳答案
您可能想要使用 GetActiveWindow api 函数。
[DllImport("user32.dll")]
static extern IntPtr GetActiveWindow();
IntPtr handle = GetActiveWindow();
尝试最小化窗口以查看是否获得正确的句柄。
private const int SW_SHOWMINIMIZED = 2;
[DllImport("user32.dll")]
private static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow)
ShowWindowAsync(hWnd, SW_SHOWMINIMIZED);
关于c# - 在 C# 中获取 Outlook 事件窗口句柄 hwnd,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36788251/