WMI How to convert the query information into a handle

Afon.zhang 396 Reputation points
2020-12-22T12:40:05.383+00:00

Is there any way to convert the information found through the WM query into a handle?

I've got three monitors, one of which I've disconnected through Windows settings

Through the C ා code,

 managementobjectsearcher disp = new managementobjectsearcher (@ "root / WMI", "select * from wmimonitorid");

foreach (ManagementObject mo in disp.Get ())

{

}

Three displays are available

The output information is as follows:

Active: True

Ins tanceName:DISPLAY \AOC2252\4&1ef5b1b7&0&UID206355_0

Manufac turerName:System.UInt16 []strData=AOC

Prod uctCodeID:System.UInt16 []strData=2252

Seria lNumberID:System.UInt16 []strData=HLDF51A015368

UserFri endlyName:System.UInt16 []strData=2252W

UserFriendlyN ameLength:13

WeekOfMa nufacture:20

YearOfMa nufacture:2015

Active:True

Ins tanceName:DISPLAY \BEA2313\4&1ef5b1b7&0&UID13762560_0

Manufac turerName:System.UInt16 []strData=BEA

Prod uctCodeID:System.UInt16 []strData=2313

Seria lNumberID:System.UInt16 []strData=16843009

UserFri endlyName:System.UInt16 []strData=CL15-HDMI

UserFriendlyN ameLength:13

WeekOfMa nufacture:0

YearOfMa nufacture:2015

Active:True

Ins tanceName:DISPLAY \AOC2252\4&1ef5b1b7&0&UID200195_0

Manufac turerName:System.UInt16 []strData=AOC

Prod uctCodeID:System.UInt16 []strData=2252

Seria lNumberID:System.UInt16 []strData=0

UserFri endlyName:System.UInt16 []strData=2252W

UserFriendlyN ameLength:13

WeekOfMa nufacture:30

YearOfMa nufacture:2018

Is there any way to convert the information obtained into the handle of the display

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,523 questions
0 comments No comments
{count} votes

Accepted answer
  1. Rita Han - MSFT 2,161 Reputation points
    2020-12-23T02:30:15.807+00:00

    Hello @Afon.zhang ,

    A handle, is simply a number that Windows uses for internal reference to an object. You can obtain a handle from system but not convert some information to a handle.

    For a disconnected monitor, there is no valid handle to it as I pointed out in another your question.

    Refer to "Handles and Objects".

    Thank you!


    If the answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

0 additional answers

Sort by: Most helpful