7,763
社区成员
发帖
与我相关
我的任务
分享
Pid = Shell(mFileName)
Hnd = OpenProcess(PROCESS_TERMINATE, 0&, Pid)
LenName = GetWindowTextLength(Hnd) 'Hnd取不到窗口名的长度
GetWindowText Hnd, strName, LenName + 1 'Hnd取不到窗口名
Hnd = FindWindow(vbNullString, strName)
SetParent Hnd, Me.hwnd
Option Explicit
Private Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Dim IfPid As Long
Private Function EnumWindowsProc(ByVal hwnd As Long, ByVal lParam As Long) As Long
Dim Pid1 As Long
Dim wText As String * 255
GetWindowThreadProcessId hwnd, Pid1
If IfPid = Pid1 Then
GetWindowText hwnd, wText, 100
Form1.List1.AddItem "句柄:" & hwnd & " 标题:" & wText
End If
EnumWindowsProc = True
End Function
Public Sub Find_Window(ByVal Pid As Long)
IfPid = Pid
EnumWindows AddressOf EnumWindowsProc, 0
End Sub