1

I am writing an application to record some hardware information of computers in our environment and I am unclear on an enum mapping from the Win32/CIM/WMI(?) API. I am getting VideoOutputTechnology from the root/wmi/wmimonitorconnectionparams class using the Microsoft.Management.Infrastructure library. This value is UInt32 enum - the source is visible here. I have successfully mapped most of this to a C# enum, but I am unclear on how I would write out the last five values (see below). Is it true that D3DKMDT_VOT_SVIDEO_4PIN = D3DKMDT_VOT_SVIDEO = 1?

    D3DKMDT_VOT_SVIDEO               =  1,
    D3DKMDT_VOT_COMPOSITE_VIDEO      =  2,
    D3DKMDT_VOT_COMPONENT_VIDEO      =  3,
    // omitted for brevity
    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,

My version of this code looks similar to the following:

public enum WmiMonitorConnectionParamsVideoOutputTechnology : uint
{
    SVideo = 1,
    CompositeVideo = 2,
    ComponentVideo = 3,
    // Is this correct?
    SVideo4Pin = WmiMonitorConnectionParamsVideoOutputTechnology.SVideo,
    SVideo7Pin = WmiMonitorConnectionParamsVideoOutputTechnology.SVideo,
    RF = WmiMonitorConnectionParamsVideoOutputTechnology.CompositeVideo,
    RCA_3COMPONENT = WmiMonitorConnectionParamsVideoOutputTechnology.ComponentVideo,
    BNC = WmiMonitorConnectionParamsVideoOutputTechnology.ComponentVideo,
}

I realize that this appears to be an Int32 type in this source code, but it's coming from CIM as UInt32. However, that does not change my question on mapping these enum values I found this information here.

Frankly, I'm not really sure what I'm looking at so I'm having trouble phrasing a question on Google to get the right answer.

Tu deschizi eu inchid
  • 4,117
  • 3
  • 13
  • 24
Stroniax
  • 718
  • 5
  • 15
  • @HansPassant, I appreciate you taking the effort to reply but I have no idea what you're telling me. – Stroniax Jan 29 '22 at 16:55
  • I have the query written out using the Microsoft.Management.Infrastructure library, so I'm calling `(UInt32)wmiMonitorConnectionParamsInstance.CimInstanceProperties["VideoOutputTechnology"].Value`, but I want to map this uint32 into a enum and I'm not sure how the C++ enum maps to a C# enum. Apologies for not being clear. – Stroniax Jan 29 '22 at 18:31
  • Your `enum` is already declared as `uint` so not sure what you are really asking. Everything looks correct so far. You can just cast it `(WmiMonitorConnectionParamsVideoOutputTechnology) (uint) wmiMonitorConnectionParamsInstance.CimInstanceProperties["VideoOutputTechnology"].Value` – Charlieface Jan 29 '22 at 20:18
  • Basically just trying to figure out if this statement is true: Is it true that `D3DKMDT_VOT_SVIDEO_4PIN` == `D3DKMDT_VOT_SVIDEO` == `1`? Based on the source code, I am not sure if there is any difference between the first two values, which may have the numeric representation of `1`, I think. – Stroniax Jan 29 '22 at 20:45
  • 1
    No there isn't, by definition they are all exactly the same. I think the idea is that on some systems some values change depending on compiler options – Charlieface Jan 29 '22 at 21:18

0 Answers0