怎样获取系统的分辨率???

TORY 2004-08-25 09:00:53
谢谢!
...全文
202 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
xanger 2004-09-03
  • 打赏
  • 举报
回复
'声明API函数
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetDeviceCaps Lib "gdi32" (ByVal hdc As Long, ByVal nIndex As Long) As Long
Private Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long) As Long


Public Sub DeviceInfo(DisplayX As Integer, DisplayY As Integer, DisplayColor As Integer)
Dim hdesktopwnd
Dim hdccaps
Dim lblRes As String
Dim DisplayBits
Dim DisplayPlanes
Dim RetVal
hdccaps = GetDC(hdesktopwnd)
DisplayBits = GetDeviceCaps(hdccaps, 12)
DisplayPlanes = GetDeviceCaps(hdccaps, 14)
DisplayX = GetDeviceCaps(hdccaps, 8)
DisplayY = GetDeviceCaps(hdccaps, 10)
RetVal = ReleaseDC(hdesktopwnd, hdccaps)
Select Case DisplayBits
Case 1
If DisplayPlanes = 1 Then
DisplayColor = 1
Else
If DisplayPlanes = 4 Then DisplayColor = 4 Else DisplayColor = 0
End If
Case 8
DisplayColor = 8
Case 16
DisplayColor = 16
Case 24
DisplayColor = 24
Case 32
DisplayColor = 32
Case Else
DisplayColor = 0 '未知色彩度
End Select
End Sub

---------------------------------------------------------------

根本不用那么复杂的,楼主可以试一下这个:

Print Screen.Width / Screen.TwipsPerPixelX
Print Screen.Height / Screen.TwipsPerPixelY



今天怎么这么多人问这个:(
自己看看多好,也不用浪费分了:)
starsoulxp 2004-09-03
  • 打赏
  • 举报
回复
ResWidth = Screen.Width/Screen.TwipsPerPixelX

ResHeight = Screen.Height/Screen.TwipsPerPixelY

ScreenRes = ResWidth & "x" & ResHeight

ResWidth和ResHeight分别表示屏幕的宽和高,比如这样的结果:

800x600
___________________________________________________________________

当然,也可以利用API函数
Private Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, ByRef lpvParam As Any, ByVal fuWinIni As Long) As Long
把其中的uAction设为SPI_GETWORKAREA
qqyong 2004-08-25
  • 打赏
  • 举报
回复
Public Function GetDisplayWidth() As Integer
GetDisplayWidth = Screen.Width \ Screen.TwipsPerPixelX
End Function

Public Function GetDisplayHeight() As Integer
GetDisplayHeight = Screen.Height \ Screen.TwipsPerPixelY
End Function
laviewpbt 2004-08-25
  • 打赏
  • 举报
回复
private sub main()
dim x,y
x=screen.width/screen.twipsperpixelx
y=screen.height/screen.twipsperpixely
msgbox"你的电脑的分辨率是" & x & "*" & y
end
end sub

1,486

社区成员

发帖
与我相关
我的任务
社区描述
VB API
社区管理员
  • API
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧