Open Event of Window and Handle of Window

后端 未结 1 381
走了就别回头了
走了就别回头了 2021-01-27 07:53

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         


        
相关标签:
1条回答
  • 2021-01-27 08:19

    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;
                            }
    
                        }
    
    0 讨论(0)
提交回复
热议问题