怎么能更改win2000的屏幕分辨率?
现在的所有代码好像只能更改98的分辨率
对2000好像无效
问题点数:40、回复次数:7Top
1 楼liuzhanwen(研究一下!)回复于 2002-06-02 16:25:14 得分 20
取得螢幕解析度
方法一
x = Screen.Width \ Screen.TwipsPerPixelX
y = Screen.Height \ Screen.TwipsPerPixelY
方法二
Private Declare Function GetSystemMetrics Lib "user32" _
( ByVal nIndex As Long) As Long
Private Const SM_CXSCREEN = 0
Private Const SM_CYSCREEN = 1
簡單的幾行 結果就傳回來的
Dim x As Long, y As Long
x = GetSystemMetrics(SM_CXSCREEN)
y = GetSystemMetrics(SM_CYSCREEN)
如何設定螢幕解析度
方法一
說明
原則上,只改這一次,下一次開機會還原,但如果需重開機,才會Update Registry中的設定,並重開機。
如果要永久設定其設定值,請將
b = ChangeDisplaySettings(DevM, 0) 改成
b = ChangeDisplaySettings(DevM, CDS_UPDATEREGISTRY)
程式
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_PELSWIDTH = &H80000
Const DM_PELSHEIGHT = &H100000
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 i As Long
Dim b As Long
Dim ans as Long
Dim a As Long
a = EnumDisplaySettings(0, 0, DevM) 'Initial Setting
DevM.dmFields = DM_PELSWIDTH Or DM_PELSHEIGHT
DevM.dmPelsWidth = 800 '設定成想要的解析度
DevM.dmPelsHeight = 600
b = ChangeDisplaySettings(DevM, 0) 'Changed Only this time
If b = DISP_CHANGE_RESTART Then
ans = MsgBox("要重開機設定才能完成,重開?", vbOKCancel)
If ans = 1 Then
b = ChangeDisplaySettings(DevM, CDS_UPDATEREGISTRY)
'after this , Will Update in Registry
Call ExitWindowsEx(EWX_REBOOT, 0)
End If
Else
If b <> DISP_CHANGE_SUCCESSFUL Then
Call MsgBox("設定有誤", vbCritical)
End If
End If
End Sub
方法二
呼叫控制台中的顯示器去設定
rundll32.exe shell32.dll,Control_RunDLL desk.cpl,,1",vbNormalFocus
Top
2 楼liuzhanwen(研究一下!)回复于 2002-06-02 16:25:31 得分 0
Private Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
x = GetSystemMetrics(0) '宽度
y = GetSystemMetrics(1) '高度
Top
3 楼liuzhanwen(研究一下!)回复于 2002-06-02 16:26:11 得分 0
Private Const SM_CXSCREEN = 0
Private Const SM_CYSCREEN = 1Top
4 楼wyarrant(ostrich)回复于 2002-06-02 16:33:28 得分 0
to: liuzhanwen(研究一下!)
请解释一下:
Private Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
x = GetSystemMetrics(0) '宽度
y = GetSystemMetrics(1) '高度
对于调整分辨率有什么作用呢?
要求是:
在程序启动时自动设为800*600,并且在程序结束时改回原来的分辨率
Top
5 楼wyarrant(ostrich)回复于 2002-06-02 16:34:58 得分 0
to: liuzhanwen(研究一下!)
请解释一下:
Private Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
x = GetSystemMetrics(0) '宽度
y = GetSystemMetrics(1) '高度
对于调整分辨率有什么作用呢?
要求是:
在程序启动时自动设为800*600,并且在程序结束时改回原来的分辨率
Top
6 楼wgku(云霄)回复于 2002-06-02 22:00:54 得分 10
2000下的?UPTop
7 楼sunxl(小呆)回复于 2002-06-04 19:03:52 得分 10
upTop
8 楼wyarrant(ostrich)回复于 2002-06-05 08:10:49 得分 0
高手别都隐着呀Top




