TeamViewer Monitor Driver breaks EnumDisplayDevices Win API Function

shaneh20
shaneh20 Posts: 1
edited May 2023 in General questions

Hi, I have built a .Net Application that runs in the background which automatically detects connected Displays. It does this by calling the EnumDisplayDevices Win API function and normally works fine.

However, when the TeamViewer Monitor Driver is installed, it prevents my application from detecting Displays properly. I figured out that when my application calls the EnumDisplayDevices function while the Monitor Driver is installed, it no longer returns certain properties like it normally does (e.g. the DISPLAY_DEVICE.DevicePath property).

Here's my Display detection VB.Net code that fails:

 

Dim displayDevice As New DISPLAY_DEVICE
displayDevice.cb = Marshal.SizeOf(displayDevice)
Dim id As UInteger = 0
While EnumDisplayDevices(Nothing, id, displayDevice, 0)
displayDevice.cb = Marshal.SizeOf(displayDevice)
EnumDisplayDevices(displayDevice.DeviceName, 0, displayDevice, EDD_GET_DEVICE_INTERFACE_NAME)
Debug.WriteLine("DeviceString: " & displayDevice.DeviceString?.TrimEnd)

'The following line does not returning anything when the Monitor Driver is installed...
Debug.WriteLine("DeviceID: " & displayDevice.DeviceID.ToUpper)
id = CUInt(id + 1)
End While

 

Is this a known issue and is their a workaround (other than uninstalling the Monitor Driver)?

Thanks