Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows 10应用程序如何从父进程获取子进程主窗口句柄_Windows_Powershell_Windows 10_Child Process_Wmi Query - Fatal编程技术网

Windows 10应用程序如何从父进程获取子进程主窗口句柄

Windows 10应用程序如何从父进程获取子进程主窗口句柄,windows,powershell,windows-10,child-process,wmi-query,Windows,Powershell,Windows 10,Child Process,Wmi Query,您好,在Windows 10中,一些应用程序,如calculator,如果我运行calc.exe,它将生成calculator.exe并立即退出cal.exe。我的要求是获取此子进程(calculator.exe)的主窗口句柄 为了从父进程获取子进程,我尝试了遵循poweshell脚本。 函数查找子进程{ 参数($ID=$PID) 获取WmiObject-类Win32_进程-筛选器“ParentProcessID=$ID”| 选择对象-属性ProcessName、ProcessID、命令行 }

您好,在Windows 10中,一些应用程序,如calculator,如果我运行calc.exe,它将生成calculator.exe并立即退出cal.exe。我的要求是获取此子进程(calculator.exe)的主窗口句柄 为了从父进程获取子进程,我尝试了遵循poweshell脚本。 函数查找子进程{ 参数($ID=$PID)

获取WmiObject-类Win32_进程-筛选器“ParentProcessID=$ID”| 选择对象-属性ProcessName、ProcessID、命令行 }

这在记事本之类的应用程序中很少见,但我并没有为计算器和internet explorer之类的进程提供子进程。。
谢谢

这方面不存在通用解决方案。进程可以有许多直接和间接的子进程。visa versa每个进程都继承了进程id(通常是父进程,但不总是),但该id仅在父进程运行之前有效。退出后-此id已不指向任何内容,然后可以重新用于另一个进程或线程,并且窗口也可以属于另一个进程。假设计算器(类ApplicationFrameWindow)不属于Calculator.exe,而是属于ApplicationFrameHost.exe。谢谢您的回复