Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for dispedid.vbs

(view source code of dispedid.vbs as plain text)

  1. 'Option Explicit
  2.  
  3. Dim blnControl
  4. Dim i, j, k
  5. Dim arrControl, arrKeys, arrRawEDID, arrSubKeys
  6. Dim objReg, wshShell
  7. Dim strComputer, strDeviceDesc, strMfg, strModel, strMsg, strKeyPath, strSerial, strSubKeyPath, strSubSubKeyPath
  8.  
  9. 'Hive Constants
  10. Const HKEY_CLASSES_ROOT       = &H80000000
  11. Const HKEY_CURRENT_USER       = &H80000001
  12. Const HKEY_LOCAL_MACHINE      = &H80000002
  13. Const HKEY_USERS              = &H80000003
  14. Const HKEY_PERFORMANCE_DATA   = &H80000004
  15. Const HKEY_CURRENT_CONFIG     = &H80000005
  16. Const HKEY_DYN_DATA           = &H80000006
  17.  
  18. 'RegFormat Constants
  19. Const REG_NONE                = 0
  20. Const REG_SZ                  = 1
  21. Const REG_EXPAND_SZ           = 2
  22. Const REG_BINARY              = 3
  23. Const REG_DWORD               = 4
  24. Const REG_DWORD_LITTLE_ENDIAN = 4
  25. Const REG_DWORD_BIG_ENDIAN    = 5
  26. Const REG_LINK                = 6
  27. Const REG_MULTI_SZ            = 7
  28. Const REG_RESOURCE_LIST       = 8
  29.  
  30. If WScript.Arguments.Count > 0 Then Syntax
  31.  
  32. strComputer = "127.0.0.1"
  33. strMsg      = ""
  34.  
  35. Set objReg = GetObject( "winmgmts:{impersonationLevel=impersonate}!//" & strComputer & "/root/default:StdRegProv" )
  36.  
  37. strKeyPath = "SYSTEM\CurrentControlSet\Enum\DISPLAY"
  38. objReg.EnumKey  HKEY_LOCAL_MACHINE, strKeyPath, arrKeys
  39.  
  40. If IsArray( arrKeys ) Then
  41. 	For i = 0 To UBound( arrKeys )
  42. 		strSubKeyPath = strKeyPath & "\" & arrKeys( i )
  43. 		objReg.EnumKey  HKEY_LOCAL_MACHINE, strSubKeyPath, arrSubKeys
  44. 		If IsArray( arrSubKeys ) Then
  45. 			For j = 0 To UBound( arrSubKeys )
  46. 				strSubSubKeyPath = strSubKeyPath & "\" & arrSubKeys( j )
  47. 				objReg.EnumKey  HKEY_LOCAL_MACHINE, strSubSubKeyPath, arrSub2
  48. 				blnControl = False
  49. 				If IsArray( arrSub2 ) Then
  50. 					For k = 0 To UBound( arrSub2 )
  51. 						If arrSub2(k) = "Control" Then blnControl = True
  52. 					Next
  53. 				End If
  54. 				If blnControl Then
  55. 					objReg.GetStringValue HKEY_LOCAL_MACHINE, strSubSubKeyPath, "Mfg", strMfg
  56. 					If IsNull( strMfg ) Then strMfg = "unknown"
  57. 					If InStr( strMfg, ";" ) Then strMfg = Mid( strMfg, InStr( strMfg, ";" ) + 1 )
  58. 					objReg.GetStringValue HKEY_LOCAL_MACHINE, strSubSubKeyPath, "DeviceDesc", strDeviceDesc
  59. 					If InStr( strDeviceDesc, ";" ) Then strDeviceDesc = Mid( strDeviceDesc, InStr( strDeviceDesc, ";" ) + 1 )
  60. 					objReg.GetBinaryValue HKEY_LOCAL_MACHINE, strSubSubKeyPath & "\Device Parameters", "BAD_EDID", arrBadEDID
  61. 					If Not IsArray( arrBadEDID ) Then
  62. 						objReg.GetBinaryValue HKEY_LOCAL_MACHINE, strSubSubKeyPath & "\Device Parameters", "EDID", arrRawEDID
  63. 						If IsArray( arrRawEDID ) Then
  64. 							Test 54
  65. 							Test 72
  66. 							Test 90
  67. 							Test 108
  68. 						End If
  69. 						strMsg = strMsg & vbCrLf _
  70. 						        & "Manufacturer   = " & strMfg        & vbCrLf _
  71. 						        & "Description    = " & strDeviceDesc & vbCrLf _
  72. 						        & "Model   (EDID) = " & strModel      & vbCrLf _
  73. 						        & "Serial# (EDID) = " & strSerial     & vbCrLf
  74. 					End If
  75. 				End If
  76. 			Next
  77. 		End If
  78. 	Next
  79. End If
  80.  
  81. WScript.Echo strMsg
  82.  
  83.  
  84. Sub Test( ByVal myIndex )
  85. 	Dim idx, arrTemp, arrTestModel, arrTestSerial, blnModel, blnSerial, strTemp
  86. 	arrTestModel  = Split( "0 0 0 252" )
  87. 	arrTestSerial = Split( "0 0 0 255" )
  88. 	blnModel      = True
  89. 	blnSerial     = True
  90.  
  91. 	For idx = 0 To 3
  92. 		If CInt( arrTestModel( idx )  ) <> CInt( arrRawEDID( idx + myIndex ) ) Then blnModel  = False
  93. 		If CInt( arrTestSerial( idx ) ) <> CInt( arrRawEDID( idx + myIndex ) ) Then blnSerial = False
  94. 	Next
  95.  
  96. 	If blnModel Or blnSerial Then
  97. 		For idx = 4 To 17
  98. 			Select Case arrRawEDID( myIndex + idx )
  99. 				Case 0
  100. 					strTemp = strTemp & " "
  101. 				Case 7
  102. 					strTemp = strTemp & " "
  103. 				Case 10
  104. 					strTemp = strTemp & " "
  105. 				Case 13
  106. 					strTemp = strTemp & " "
  107. 				Case Else
  108. 					strTemp = strTemp & Chr( arrRawEDID( myIndex + idx ) )
  109. 			End Select
  110. 		Next
  111. 		strTemp = Trim( strTemp )
  112. 		' The following lines are disabled because they truncate model names at the first space
  113. 		'If InStr( strTemp, " " ) Then
  114. 		'	arrTemp = Split( strTemp, " " )
  115. 		'	strTemp = arrTemp(0)
  116. 		'End If
  117. 		If blnModel  Then strModel  = strTemp
  118. 		If blnSerial Then strSerial = strTemp
  119. 	End If
  120. End Sub
  121.  
  122.  
  123. Sub Syntax
  124. 	strMsg = vbCrLf _
  125. 	       & "DispEDID.vbs,  Version 2.30" _
  126. 	       & vbCrLf _
  127. 	       & "Read and parse monitor EDID asset information from the registry" _
  128. 	       & vbCrLf & vbCrLf _
  129. 	       & "Usage:  DISPEDID.VBS" _
  130. 	       & vbCrLf & vbCrLf _
  131. 	       & "Based on a script by Michael Baird (link no longer available)" _
  132. 	       & vbCrLf & vbCrLf _
  133. 	       & "(Re)written by Rob van der Woude" _
  134. 	       & vbCrLf _
  135. 	       & "http://www.robvanderwoude.com"
  136. 	WScript.Echo strMsg
  137. 	WScript.Quit 1
  138. End Sub
  139.  

page last uploaded: 2017-04-06, 13:33