Open Event of Window and Handle of Window

ⅰ亾dé卋堺 提交于 2019-12-04 06:37:46

问题


How do I get a window handle (IntPtr) from the Outlook window I have just opened?

    OutLook.Items items = oFolder.Items;

    foreach (OutLook.MailItem mail in items)
    {

          mail.Display();

          //IntPtr a = (System.IntPtr)mail.GetInspector.Parent;

I am new to C sharp.


回答1:


I think I'll have to settle with this solution. I was hoping for something a lot more solid, but this is about 80% solid. Interested to see what others think.

Its standard get window by window title:

                    Process[] processes = Process.GetProcessesByName("OUTLOOK");

                    foreach (Process p in processes)
                    {

                        if (p.MainWindowTitle == mail.GetInspector.Caption)
                        {

                            handle = p.MainWindowHandle;

                            break;
                        }

                    }


来源:https://stackoverflow.com/questions/5607807/open-event-of-window-and-handle-of-window

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!