2

i tried to read MainWindowHanlde For Acrobat Reader 10 Process so i can SetParent API i tried this

private Process pDocked;
private IntPtr hWndDocked;
pDocked = Process.Start(path, PDFPath);
while (hWndDocked == IntPtr.Zero)
{
    pDocked.WaitForInputIdle(1000);
    pDocked.Refresh();
    if (pDocked.HasExited)
    {
        return;
    }
    hWndDocked = pDocked.MainWindowHandle;
}

and the result is hWndDocked = 0 even i tried this on acrobat reader 9 and i got the MainWindowHandle but it didn't work on acrobat reader 10

please help And Thanks

4

1 回答 1

1

我有同样的问题,发现当以下属性为真时,没有MainWindowHandle,如果“主窗体”有子窗口,那么进程的MainWindowHandle将是子窗口句柄而不是预期的主窗口。诡异的!!!希望我能理解为什么。但是一旦我发现这个,我就会以另一种方式解决我的问题(在我的情况下,我并不真的需要 MainWindowHandle)!

以下情况时:

public frmMain()
        {
            InitializeComponent();
            this.ShowInTaskbar = false;
            this.ShowIcon = false;
        }

没有 MainWindowHandle (=0)!!

如果您创建子窗口,在这种情况下,进程的 MainWindowHandle 将是 frmLogon 的句柄:

private void frmMain_Load(object sender, EventArgs e)
        {
            frmLogon frm = new frmLogon();
            frm.Show();
        }

关闭frmLogon和进程的MainWindowHandle归零(=0)!!

希望这些信息有帮助!

于 2015-09-26T08:31:48.307 回答