VB中利用API函数实现屏幕颜色数设定
原则上只改这一次,下次再恢复。但是,如果您需要重新启动,您将更新注册表中的设置并重新启动。
若要永久设置其设置,请将
b = ChangeDisplaySettings(DevM,0)
换成
b = ChangeDisplaySettings(DevM,CDS_UPDATEREGISTRY)
注意:
DevM.dmBitsPERPel用于设置颜色的数量。其实应该说每个像素需要显示多少位。
4-> 16色
8-> 256色
16-> 65536色等等。
option Explicit
Private Declare Function EnumDisplaySettings Lib " user 32 " Alias _
" EnumDisplaySettings sa "(ByVal lpszDeviceName为Long,_
ByVal iModeNum为Long,lpDevMode为Any)为Long
私有声明函数ChangeDisplaySettings Lib " user 32 " Alias _
" ChangeDisplaySettings sa "(lpDevMode As Any,ByVal dw flags As Long
私有声明函数ExitWindowsEx Lib " user 32 "(ByVal u flags As Long,_
ByVal dwReserved As Long)
const EWX _ REBOOT = 2 ' REBOOT
const cc device name = 32
const cc formname = 32
Const DM _ BITSPERPEL = & h 40000
Const DISP _更改_成功= 0
Const DISP _更改_重启= 1
Const CDS _更新注册表= 1
私有类型DEVMODE
dmDeviceName As String * CCDEVICENAME
dmSpecVersion As Integer
dmDriverVersion As Integer
dmSize As Integer
dmDriverExtra As Integer
0条评论