我的电脑上有一个应用程序。 我可以获得该应用程序的每个细节(句柄,主窗口等)
该应用程序有很多标签,我想在我自己的应用程序中读取该标签和msgbox字符串。
答案 0 :(得分: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