VBGood网站全文搜索 Google

搜索VBGood全站网页(全文搜索)
首页 - 经验之谈 - 桌面的大小
发表评论(0)作者:不详, 平台:VB6.0+Win98, 阅读:10965, 日期:2001-12-10
桌面的大小
Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type

Public Const SPI_GETWORKAREA = 48

Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, lpvParam As Any, ByVal fuWinIni As Long) As Long

Private Sub Command1_Click()

Dim lRet As Long
Dim apiRECT As RECT

lRet = SystemParametersInfo(SPI_GETWORKAREA, vbNull, apiRECT, 0)

If lRet Then
Print "Left: " & apiRECT.Left
Print "Top: " & apiRECT.Top
Print "Width: " & apiRECT.Right - apiRECT.Left
Print "Height: " & apiRECT.Bottom - apiRECT.Top
Else
Print "调用 SystemParametersInfo 失败"
End If

End Sub

更新 其他方法:
Sub Command1_Click ()
CR$ = Chr$(13) + Chr$(10)
TWidth% = screen.Width screen.TwipsPerPixelX
THeight% = screen.Height screen.TwipsPerPixelY

MsgBox "屏幕大小为" + CR$ + CR$ + Str$(TWidth%) + " x" + Str$(THeight%), 64, "Info"
End Sub