读取 MainWindowHandle 来了解进程

发布于 2024-11-18 17:27:12 字数 522 浏览 3 评论 0原文

我尝试阅读 MainWindowHanlde For Acrobat Reader 10 Process,以便我可以 SetParent API 我尝试了这个

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;
}

,结果是 hWndDocked = 0 即使我在 acrobat reader 9 上尝试过这个,我得到了 MainWindowHandle 但它在 acrobat reader 10 上不起作用,

请帮忙 谢谢

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

送舟行 2024-11-25 17:27:12

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

当出现以下情况时:

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

No MainWindowHandle (=0)!!

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

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

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

希望这些信息有帮助!

I had same issue, and find that when the following properties are true,there is no MainWindowHandle, and if the "main form" have child window, then the MainWindowHandle of process will be the child window handle rather than the expected main window. WEIRD!!! wish I can understand why. but once I find this I solve my problem in another way (in my case I not really need the MainWindowHandle)!

When the following:

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

No MainWindowHandle (=0)!!

if you create sub window, in this case the MainWindowHandle of the process will be the handle of frmLogon :

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

Close the frmLogon and the MainWindowHandle of the process back to zero (=0)!!

Hope this info is helpful!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文