Dim HWD As Integer HWD = GetWindow(Me.Handle.ToInt32, GW_HWNDFIRST) Dim title As New String(Chr(0), 256) Dim tt As String Do While HWD <> 0 '''''''''''''''''''''''''这里还要注意 Dim i As Integer i = GetWindowText(HWD, title, 256) If i <> 0 Then If InStr(title, "Word") <> 0 Then '只要有word字样的都列出来 Dim str As String ListBox1.Items.Add(title) ListBox1.Items.Add(HWD.ToString) End If End If HWD = GetWindow(HWD, GW_HWNDNEXT) Loop
HWD = GetWindow(Me.Handle.ToInt32, GW_HWNDFIRST)
Dim title As New String(Chr(0), 256)
Dim tt As String
Do While HWD <> 0 '''''''''''''''''''''''''这里还要注意
Dim i As Integer
i = GetWindowText(HWD, title, 256) If i <> 0 Then
If InStr(title, "Word") <> 0 Then '只要有word字样的都列出来
Dim str As String
ListBox1.Items.Add(title)
ListBox1.Items.Add(HWD.ToString)
End If
End If
HWD = GetWindow(HWD, GW_HWNDNEXT)
Loop
[DllImport("user32.dll")]//引入DLL
public static extern IntPtr FindWindow(string strclassName, string strWindowName);IntPtr xx=FindWindow("OpusApp",null);
这里的XX就是你要的句柄