更新RDS预览标题

时间:2019-02-11 17:09:12

标签: vb.net rds

对于某些应用程序,我们正在从Citrix迁移到RDS。但是,在初始部署中,我们注意到任务栏窗口标题(即,您将鼠标悬停或单击任务栏中的图标,并获得带有标题的平铺预览)不会随应用程序的窗口标题一起更新。相反,它说(RDBROKER.SITE.NET)。更糟糕的是,它有点不一致。

RDS_Title_Issue

我修改了this answer中的代码,并在表单加载期间使用了该代码:

Class NameChangeTracker
    Delegate Sub WinEventDelegate(ByVal hWinEventHook As IntPtr, ByVal eventType As UInteger, ByVal hwnd As IntPtr, ByVal idObject As Integer, ByVal idChild As Integer, ByVal dwEventThread As UInteger, ByVal dwmsEventTime As UInteger)
    <DllImport("user32.dll")>
    Private Shared Function SetWinEventHook(ByVal eventMin As UInteger, ByVal eventMax As UInteger, ByVal hmodWinEventProc As IntPtr, ByVal lpfnWinEventProc As WinEventDelegate, ByVal idProcess As UInteger, ByVal idThread As UInteger, ByVal dwFlags As UInteger) As IntPtr

    End Function
    <DllImport("user32.dll")>
    Private Shared Function UnhookWinEvent(ByVal hWinEventHook As IntPtr) As Boolean

    End Function
    Const EVENT_OBJECT_NAMECHANGE As UInteger = &H800C
    Const WINEVENT_OUTOFCONTEXT As UInteger = 0
    Shared procDelegate As WinEventDelegate = New WinEventDelegate(AddressOf WinEventProc)

    Public Shared Sub Main()
        Dim hhook As IntPtr = SetWinEventHook(EVENT_OBJECT_NAMECHANGE, EVENT_OBJECT_NAMECHANGE, IntPtr.Zero, procDelegate, 0, 0, WINEVENT_OUTOFCONTEXT)
        'MessageBox.Show("Tracking name changes on HWNDs, close message box to exit.")
        UnhookWinEvent(hhook)
    End Sub

    Private Shared Sub WinEventProc(ByVal hWinEventHook As IntPtr, ByVal eventType As UInteger, ByVal hwnd As IntPtr, ByVal idObject As Integer, ByVal idChild As Integer, ByVal dwEventThread As UInteger, ByVal dwmsEventTime As UInteger)
        If idObject <> 0 OrElse idChild <> 0 Then
            Return
        End If

        'Console.WriteLine("Text of hwnd changed {0:x8}", hwnd.ToInt32())
    End Sub
End Class

此代码不正确吗?我还需要做些其他事情才能使它正常工作吗?我可以使用ctrl+alt+end手动执行此操作,以强制更新RDS窗口,但是我们将无法使用户执行此操作。

0 个答案:

没有答案