2011-11-06 16 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

相關問題