VB利用API函数设定屏幕颜色数

寻找幸福753

寻找幸福753

2016-02-19 18:36

下面请跟着图老师小编一起来了解下VB利用API函数设定屏幕颜色数,精心挑选的内容希望大家喜欢,不要忘记点个赞哦!
原则上,只改这一次,下一次开机会还原,但假如需重开机,才会Update Registry中的设定,并重开机。 !-- frame contents -- !-- /frame contents --

  假如要永久设定其设定值,请将

  

  b = ChangeDisplaySettings(DevM, 0)

  改成

  

  b = ChangeDisplaySettings(DevM, CDS_UPDATEREGISTRY)

  注:

  DevM.dmBitsPerPel 便是设定颜色数,其实应说每个Pixel要多少Bits来显示

  4 -- 16色

  8 -- 256色

  16 -- 65536色 以此类推

  
  
  
推荐文章:搞笑之可爱水果表情  清新素洁水仙壁纸集


     Option EXPlicit

  Private Declare Function EnumDisplaySettings Lib "user32" Alias _

  "EnumDisplaySettingsA" (ByVal lpszDeviceName As Long, _

  ByVal iModeNum As Long, lpDevMode As Any) As Long

  

  Private Declare Function ChangeDisplaySettings Lib "user32" Alias _

  "ChangeDisplaySettingsA" (lpDevMode As Any, ByVal dwflags As Long) As Long

  Private Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, _

  ByVal dwReserved As Long) As Long

  

  Const EWX_REBOOT = 2 ’ 重开机

  Const CCDEVICENAME = 32

  Const CCFORMNAME = 32

  

  Const DM_BITSPERPEL = &H40000

  Const DISP_CHANGE_SUCCESSFUL = 0

  Const DISP_CHANGE_RESTART = 1

  Const CDS_UPDATEREGISTRY = 1

  Private Type DEVMODE

  dmDeviceName As String * CCDEVICENAME

  dmSpecVersion As Integer

  dmDriverVersion As Integer

  dmSize As Integer

  dmDriverExtra As Integer

  

  dmFields As Long

  dmOrientation As Integer

  dmPaperSize As Integer

  dmPaperLength As Integer

  dmPaperWidth As Integer

  dmScale As Integer

  dmCopies As Integer

  dmDefaultSource As Integer

  dmPrintQuality As Integer

  dmColor As Integer

  dmDuplex As Integer

  dmYResolution As Integer

  dmTTOption As Integer

  dmCollate As Integer

  

  dmFormName As String * CCFORMNAME

  dmUnusedPadding As Integer

  dmBitsPerPel As Integer

  dmPelsWidth As Long

  dmPelsHeight As Long

  dmDisplayFlags As Long

  dmDisplayFrequency As Long

  End Type

  Private DevM As DEVMODE

  Private Sub Command1_Click()

  Dim a As Boolean

  Dim i As Long

  Dim b As Long

  Dim ans As Long

  a = EnumDisplaySettings(0, 0, DevM) ’Initial Setting

  DevM.dmBitsPerPel = 8 ’设定成256色

  DevM.dmFields = DM_BITSPERPEL

  b = ChangeDisplaySettings(DevM, 0)

  If b = DISP_CHANGE_RESTART Then

   ans = MsgBox("要重开机设定才能完成,重开?", vbOKCancel)

   If ans = 1 Then

  b = ChangeDisplaySettings(DevM, CDS_UPDATEREGISTRY)

  Call ExitWindowsEx(EWX_REBOOT, 0)

   End If

  Else

   If b <> DISP_CHANGE_SUCCESSFUL Then

  Call MsgBox("设定有误", vbCritical)

   End If

  End If

  End Sub

  
  
  
  
推荐文章:搞笑之可爱水果表情  清新素洁水仙壁纸集


  
展开更多 50%)
分享

猜你喜欢

VB利用API函数设定屏幕颜色数

编程语言 网络编程
VB利用API函数设定屏幕颜色数

在VB中调用API函数动态改变及恢复屏幕设置

编程语言 网络编程
在VB中调用API函数动态改变及恢复屏幕设置

s8lol主宰符文怎么配

英雄联盟 网络游戏
s8lol主宰符文怎么配

在VB中使用API函数(Any)

ASP
在VB中使用API函数(Any)

API函数在VB中的应用

编程语言 网络编程
API函数在VB中的应用

lol偷钱流符文搭配推荐

英雄联盟 网络游戏
lol偷钱流符文搭配推荐

API函数在VB开发中的应用

编程语言 网络编程
API函数在VB开发中的应用

VB中访问API函数之防错技巧

编程语言 网络编程
VB中访问API函数之防错技巧

lolAD刺客新符文搭配推荐

英雄联盟
lolAD刺客新符文搭配推荐

win10系统怎么录制声音

win10系统怎么录制声音

JBuilder2005实现重构之类继承体系间

JBuilder2005实现重构之类继承体系间
下拉加载更多内容 ↓