2011-11-06 43 views

回答

1

你可以试试这个(这pinvoke已经很好地覆盖):

<DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _ 
Private Shared Function GetWindowText(ByVal hwnd As IntPtr, ByVal lpString As StringBuilder, ByVal cch As Integer) As Integer 
End Function 

<DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _ 
Private Shared Function GetWindowTextLength(ByVal hwnd As IntPtr) As Integer 
End Function 

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button2.Click 
    Dim length As Integer = GetWindowTextLength(otherAppLabelHandle) 
    Dim sb As New StringBuilder(length + 1) 
    GetWindowText(otherAppLabelHandle, sb, sb.Capacity) 
    MessageBox.Show(sb.ToString()) 
End Sub 
+0

和我如何会得到一个标签的手柄从另一个应用程序? – sarkolata

+0

@sarkolata你的文章说你有应用程序的每一个细节,包括手柄。你有什么细节? – LarsTech

+0

对我的帖子感到抱歉,我看到它的误解。 我可以得到主窗口句柄,主窗口标题等。 (所有从system.diagonistics.process类获取属性) 我已经从我的vb.net程序启动应用程序。 – sarkolata

相关问题