文章关键字 ‘分辨率’

用Shell.Application获取图片分辨率

2010年11月23日,星期二

昨天有人在博客里留言:“获取图片分辨率也可以用Shell.Application,我比较喜欢用这个。”简单Google了一下,未果,于是发邮件请教了一下,很快就有了回复。

Path = "C:\test.jpg"
arr = Split(Path,"\")
FileName = arr(Ubound(arr))
FolderPath = Left(Path, Len(Path) - Len(FileName) - 1)
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(FolderPath)
set objFolderItem = objFolder.ParseName(FileName)
Width = objFolder.GetDetailsOf(objFolderItem, 162)
Height = objFolder.GetDetailsOf(objFolderItem, 164)
Msgbox "Width: " & Width & " Height: " & Height

碰到VBS高手了。

用VBS获取屏幕分辨率

2010年09月2日,星期四

我想到的方法有两种。

一种是WMI中的Win32_DesktopMonitor类

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_DesktopMonitor",,48)

For Each objItem in colItems
	WScript.Echo "ScreenHeight: " & objItem.ScreenHeight
	WScript.Echo "ScreenWidth: " & objItem.ScreenWidth
Next

一种是HTML DOM中的screen对象

Dim IE
Set IE = CreateObject("InternetExplorer.Application")
IE.Navigate "about:blank"
Set screen = IE.Document.parentWindow.screen
WScript.Echo "ScreenHeight: " & screen.height
WScript.Echo "ScreenWidth: " & screen.width

参考链接
  1. Win32_DesktopMonitor Class
  2. screen Object