How to get all video modes from controller?
;==========================================================================================================================================
;
; How to get a list of all various video modes, which a video controller can support?
;
; (c)Detlev Dalitz.20120418.
;==========================================================================================================================================
;
; Video modes are defined by the possible horizontal and vertical resolutions, refresh rate, scan mode, and number of color settings supported by a controller.
;
; Starting with Windows Vista, hardware that is not compatible with Windows Display Driver Model (WDDM) returns inaccurate property values for instances of this class.
; Windows Server 2003, Windows XP, Windows 2000, and Windows NT 4.0:  This class returns accurate data.
;
;   class CIM_VideoControllerResolution
;   {
;     string Caption;
;     string Description;
;     uint32 HorizontalResolution;
;     uint32 MaxRefreshRate;
;     uint32 MinRefreshRate;
;     uint64 NumberOfColors;
;     uint32 RefreshRate;
;     uint16 ScanMode;
;     string SettingID;
;     uint32 VerticalResolution;
;   };
;==========================================================================================================================================


;Test.

DirChange (DirScript ())
strFileThis = IntControl (1004, 0, 0, 0, 0)
strFileOut1 = ItemReplace ("out.1.txt", -1, strFileThis, ".")
strFileOut2 = ItemReplace ("out.2.txt", -1, strFileThis, ".")
strFileOut3 = ItemReplace ("out.3.txt", -1, strFileThis, ".")


; Test 1.
; Get all items of SettingID. Example string: "320 x 200 x 256 colors @ 60 Hertz".

strComputer = "."
objWMIService = GetObject ("winmgmts:\\" : strComputer : "\root\CIMV2")
colItems = objWMIService.ExecQuery("SELECT * FROM CIM_VideoControllerResolution")

strListRes = ""
ForEach objItem In colItems
   strListRes = strListRes : @CRLF : objItem.SettingID
Next
strListRes = StrSub (strListRes, 3, -1)

If strListRes != ""
   intBytes = FilePut (strFileOut1, strListRes) ; Put the string list into text file and display file content.
   Run (strFileOut1, "")
EndIf
Drop (strListRes)


; Test 2.
; Get all items of SettingID. Example string: "320 x 200 x 256 colors @ 60 Hertz".
; Destruct the SettingID string and create a sort index, sorted by "Refresh_ResH_ResV_Colors".

strComputer = "."
objWMIService = GetObject ("winmgmts:\\" : strComputer : "\root\CIMV2")
colItems = objWMIService.ExecQuery("SELECT * FROM CIM_VideoControllerResolution")

arrVCR = ArrDimension (0, 5)
ForEach objItem In colItems
   strRes = objItem.SettingID
   strRes = StrClean (strRes, "0123456789x@", "", @TRUE, 2)
   strRes = StrReplace (strRes, "@", "x")
   arrRes = Arrayize (strRes, "x")
   intRow = ArrInfo (arrVCR, 1)
   ArrayRedim (arrVCR, intRow + 1, -1)
   arrVCR[intRow, 0] = arrRes[0]
   arrVCR[intRow, 1] = arrRes[1]
   arrVCR[intRow, 2] = arrRes[2]
   arrVCR[intRow, 3] = arrRes[3]
   arrVCR[intRow, 4] = StrFixLeft (arrRes[3], " ", 4) : StrFixLeft (arrRes[0], " ", 6) : StrFixLeft (arrRes[1], " ", 6) : StrFixLeft (arrRes[2], " ", 12) ; My sort index.
Next
ArraySort (arrVCR, @DESCENDING, 4) ; Sort by Refresh_ResH_ResV_Colors.
ArrayRemove (arrVCR, 4, 2)

If ArrInfo (arrVCR, 2)
   intBytes = ArrayFilePutCSV (strFileOut2, arrVCR) ; Put the array list into text file and display file content.
   Run (strFileOut2, "")
EndIf
Drop (arrVCR)


; Test 3.
; Same as Test 2, but use all the class items, and create a sort index, sorted by "Refresh_ResH_ResV_Colors".

strComputer = "."
objWMIService = GetObject ("winmgmts:\\" : strComputer : "\root\CIMV2")
colItems = objWMIService.ExecQuery("SELECT * FROM CIM_VideoControllerResolution")

arrVCR = ArrDimension (0, 11)
ForEach objItem In colItems
   intRow = ArrInfo (arrVCR, 1)
   ArrayRedim (arrVCR, intRow + 1, -1)
   arrVCR[intRow, 0] = objItem.Caption
   arrVCR[intRow, 1] = objItem.Description
   arrVCR[intRow, 2] = objItem.HorizontalResolution
   arrVCR[intRow, 3] = objItem.MaxRefreshRate
   arrVCR[intRow, 4] = objItem.MinRefreshRate
   arrVCR[intRow, 5] = objItem.NumberOfColors
   arrVCR[intRow, 6] = objItem.RefreshRate
   arrVCR[intRow, 7] = objItem.ScanMode
   arrVCR[intRow, 8] = objItem.SettingID
   arrVCR[intRow, 9] = objItem.VerticalResolution
   arrVCR[intRow, 10] = StrFixLeft (arrVCR[intRow, 6], " ", 4) : StrFixLeft (arrVCR[intRow, 2], " ", 6) : StrFixLeft (arrVCR[intRow, 9], " ", 6) : StrFixLeft (arrVCR[intRow, 5], " ", 12)
Next
ArraySort (arrVCR, @DESCENDING, 10) ; Sort by Refresh_ResH_ResV_Colors.
ArrayRemove (arrVCR, 10, 2) ; My sort index column.
ArrayRemove (arrVCR, 09, 2) ; VerticalResolution.
ArrayRemove (arrVCR, 08, 2) ; SettingID.
ArrayRemove (arrVCR, 07, 2) ; ScanMode.
ArrayRemove (arrVCR, 06, 2) ; RefreshRate.
ArrayRemove (arrVCR, 05, 2) ; NumberOfColors.
ArrayRemove (arrVCR, 04, 2) ; MinRefreshRate.
ArrayRemove (arrVCR, 03, 2) ; MaxRefreshRate.
ArrayRemove (arrVCR, 02, 2) ; HorizontalResolution.
ArrayRemove (arrVCR, 01, 2) ; Description.
; ArrayRemove (arrVCR, 00, 2) ; Caption.

If ArrInfo (arrVCR, 2)
   intBytes = ArrayFilePutCSV (strFileOut3, arrVCR) ; Put the array list into text file and display file content.
   Run (strFileOut3, "")
EndIf
Drop (arrVCR)


:CANCEL
FileDelete (strFileOut1)
FileDelete (strFileOut2)
FileDelete (strFileOut3)
Exit
;==========================================================================================================================================