Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/unit-testing/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
lauch exe在vb.net中填充并获取其windows标题_Vb.net - Fatal编程技术网

lauch exe在vb.net中填充并获取其windows标题

lauch exe在vb.net中填充并获取其windows标题,vb.net,Vb.net,我有这个密码 Private Sub tmrMain_Tick(sender As Object, e As EventArgs) Handles tmrMain.Tick EnumWindows(AddressOf Enumerator, 0) End Sub Private Function Enumerator(ByVal hwnd As IntPtr, ByVal lParam As Integer) As Boolean If

我有这个密码

    Private Sub tmrMain_Tick(sender As Object, e As EventArgs) Handles tmrMain.Tick
        EnumWindows(AddressOf Enumerator, 0)
    End Sub

    Private Function Enumerator(ByVal hwnd As IntPtr, ByVal lParam As Integer) As Boolean
        If IsWindowVisible(hwnd) Then
            Dim text As String
            Dim pPid As Integer
            GetWindowText(hwnd, text, Int16.MaxValue) 'return integer value
            Dim tempprocess As Process
            GetWindowThreadProcessId(hwnd, pPid)
            tempprocess = Process.GetProcessById(pPid)
            text = tempprocess.MainWindowTitle
            If "Holyrics is free - v2.15.1 x64" = text Then
                contador = contador + 1
                MessageBox.Show(contador)
                tmrMain.Enabled = False
            End If
        End If
        Return True
    End Function
    Private Sub frmMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        MyProcess = Process.Start(txtNome.Text)
        MyProcess.WaitForInputIdle()
    End Sub
此exe在一段时间后将主窗口更改为“Holyrics是免费的-v2.15.1 x64”。 为什么MyProcess不自动将主窗口标题更改为“Holyrics是免费的-v2.15.1 x64”,而不使用我尝试过的if? 如何获取MyProcess生成的所有窗口的句柄?

您可能需要使用获取窗口标题的长度,然后调用
GetWindowText()
传递一个使用该容量+1初始化的StringBuilder。当然,删除
tempprocess.MainWindowTitle
&Co.
IsWindowVisible()
不是必需的。找到匹配项时返回
False
,以停止枚举。也许,执行不区分大小写的比较。