我如何知道插入的是哪个 HDMI 端口? [英] How can I know which HDMI port is plugged in?

查看:124
本文介绍了我如何知道插入的是哪个 HDMI 端口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一台带有双 hdmi 输出的计算机.当我将显示器连接到其中一个时,我想检测插入的是哪一个.

I have a computer with a dual hdmi output. I would like to detect which one is plugged in when I connect a monitor to either to one of them.

它可以借助注册表、powershell 或 C# 代码或任何其他东西.只要不是 C++.

It can be either with the help of registry, powershell or C# code, or anything. As long as it's not C++.

我尝试了各种 wmi 方法.在注册表中搜索任何可以指定 hdmi 端口的内容.但目前一无所获.

I've tried various wmi methods. Searched the registry for anything that would specify a hdmi port. But found nothing so far.

这个 stackoverflow 答案(检测/识别显示器在 Windows 7/8/10 Win32 C++ 中连接到的端口(HDMI,其他))是我发现的唯一一个关于我的需要,但我无法处理 C++ 所以从现在开始我被卡住了.

This stackoverflow answer (Detect/identify the port (HDMI, other) the monitor is connected to in Windows 7/8/10 Win32 C++) is the only one I found regarding my need, but I can't handle c++ so from now on I'm stuck.

谢谢大家

推荐答案

在 powershell 中试试这个.

Try this in powershell.

$objWMi = get-wmiobject -namespace root\WMI -computername localhost -Query "Select * from WmiMonitorConnectionParams"

foreach ($obj in $objWmi)
{
    write-host "Active:" $obj.Active
    write-host "InstanceName:" $obj.InstanceName
    write-host "VideoOutputTechnology:" $obj.VideoOutputTechnology
    write-host
    write-host "########"
    write-host
}

WmiMonitorConnectionParams 类具有返回以下内容的 VideoOutputTechnology 属性:

The WmiMonitorConnectionParams class has VideoOutputTechnology property which returns the following:

    typedef enum _D3DKMDT_VIDEO_OUTPUT_TECHNOLOGY { 
  D3DKMDT_VOT_UNINITIALIZED         = -2,
  D3DKMDT_VOT_OTHER                 = -1,
  D3DKMDT_VOT_HD15                  = 0,
  D3DKMDT_VOT_SVIDEO                = 1,
  D3DKMDT_VOT_COMPOSITE_VIDEO       = 2,
  D3DKMDT_VOT_COMPONENT_VIDEO       = 3,
  D3DKMDT_VOT_DVI                   = 4,
  D3DKMDT_VOT_HDMI                  = 5,
  D3DKMDT_VOT_LVDS                  = 6,
  D3DKMDT_VOT_D_JPN                 = 8,
  D3DKMDT_VOT_SDI                   = 9,
  D3DKMDT_VOT_DISPLAYPORT_EXTERNAL  = 10,
  D3DKMDT_VOT_DISPLAYPORT_EMBEDDED  = 11,
  D3DKMDT_VOT_UDI_EXTERNAL          = 12,
  D3DKMDT_VOT_UDI_EMBEDDED          = 13,
  D3DKMDT_VOT_SDTVDONGLE            = 14,
#if (DXGKDDI_INTERFACE_VERSION >= DXGKDDI_INTERFACE_VERSION_WDDM1_3_M1)
  D3DKMDT_VOT_MIRACAST              = 15,
#endif 
  D3DKMDT_VOT_INTERNAL              = 0x80000000,
  D3DKMDT_VOT_SVIDEO_4PIN           = D3DKMDT_VOT_SVIDEO,
  D3DKMDT_VOT_SVIDEO_7PIN           = D3DKMDT_VOT_SVIDEO,
  D3DKMDT_VOT_RF                    = D3DKMDT_VOT_COMPOSITE_VIDEO,
  D3DKMDT_VOT_RCA_3COMPONENT        = D3DKMDT_VOT_COMPONENT_VIDEO,
  D3DKMDT_VOT_BNC                   = D3DKMDT_VOT_COMPONENT_VIDEO
} D3DKMDT_VIDEO_OUTPUT_TECHNOLOGY;

这篇关于我如何知道插入的是哪个 HDMI 端口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆