VBA+WebCAM 拍个照, 留个念吧!
时 间:2011-10-06 19:40:00
作 者:dbaseIIIer ID:22003 城市:深圳
摘 要:VB能做什么一切都来自微软! 微软那么多人服待我们, 只是我们有没有真正被服待到!
正 文:
XP通用!
ME 和 Win7 都要用别的类库呢! 未找到! 啊! 示列而已, 自己玩玩@
Option Compare Database
Sub b()
Dim oWIA As WIALib.Wia
Dim d As WIALib.DeviceInfo
Dim wiaRoot As WIALib.Item
Dim wiaPics As WIALib.Collection
Dim wiaItem As WIALib.Item
Set oWIA = New WIALib.Wia
For Each d In oWIA.Devices
If d.Type = "StreamingVideo" Then ' <----- 如不筛选 StreamingVideo 是可以把 扫描仪也拿来用的
Set wiaRoot = oWIA.Create(d.ID) ' <----- 我只用第一个找到的摄像头, 有多的话 可以像QQ一样造个画面让人选用哪个摄像头
Exit For
End If
Next
'Set wiaPics = wiaRoot.GetItemsFromUI(UseCommonUI, ImageTypeColor) '<---- 这是捕获 多张图片的
Set wiaPics = wiaRoot.GetItemsFromUI(SingleImage, ImageTypeColor) '<---- 这是捕获 一张图片的
If wiaPics Is Nothing Then
Else
For Each wiaItem In wiaPics
If wiaItem.ItemType = "file;image" Then
wiaItem.Transfer "C:\" & wiaItem.Name, False '<---- 只能保存的, 后面的 True/False 是否用Async保存即再用事件捕获已存好
'<---- Access 不支持True 的呢
End If
Next
End If
End Sub
刚在网上找到 C#代码, 翻译过来的!
试过成功, 不过限制是只能在 XP下操作! 理论上在任何 VBA上都能执行.
原文在 http://www.codeproject.com/KB/dotnet/wiascriptingdotnet.aspx
Limitations
- Again, for Windows XP only! if you need .NET imaging for older systems, try this TWAIN sample
- Windows ME has an older version of WIA, but you can't use the same code/type-lib from these samples for that version.
- WIA devices must be fully detected and configured by Windows.
- As far as I know, WIA needs your app to have the [STAThread] attribute on the Main() method used to launch your application.
Item.Thumbnail
was left out as it uses an undocumented Asynchronous Pluggable Protocol (APP) and has bugs.- Code was only tested with an Olympus digi-cam, an Epson scanner, a Logitech QuickCam, and a Sony DV CamCorder, 还有我的上网本
啊, 记得引用 "Microsoft Windows Image Acquisition 1.01 Type Library" (wiascr.dll) 啊!
原文内还有使用 WIAVideo类库 的, 可是我试过, 并不能在 Access的窗体内让这控件播放 Video,
wiaVideo = new WiaVideoClass();
wiaVideo.CreateVideoByWiaDevID( wiaDeviceID, window.Handle, 0, 1 );
转为
Dim wiaVideo As WIAVIDEOLib.WiaVideo
Dim oWIA As WIALib.Wia
set wiaVideo = New WIAVIDEOLib.WiaVideo
set oWIA = New WIALib.Wia
wiaVideo.CreateVideoByWiaDevID oWIA.Devices(0).ID), me.Hwnd, 0, 1
会报错 "Visual Basic 不支持的 自动化 (Automation) 错误!"
Access软件网官方交流QQ群 (群号:54525238) Access源码网店
常见问答:
技术分类:
源码示例
- 【源码QQ群号19834647...(12.17)
- 统计当月之前(不含当月)的记录...(03.11)
- 【Access Inputbo...(03.03)
- 按回车键后光标移动到下一条记录...(02.12)
- 【Access Dsum示例】...(02.07)
- Access对子窗体的数据进行...(02.05)
- 【Access高效办公】上月累...(01.09)
- 【Access高效办公】上月累...(01.06)
- 【Access Inputbo...(12.23)
- 【Access Dsum示例】...(12.16)

学习心得
最新文章
- Access控件美化之--美化按钮...(04.19)
- Access多行文本按指定字符筛选...(04.18)
- Microsoft Access数...(04.18)
- 仓库管理实战课程(12)-月度结存...(04.16)
- 仓库管理实战课程(11)-人性化操...(04.15)
- 32位的Access软件转化为64...(04.12)
- 【Access高效办公】如何让vb...(04.11)
- 仓库管理实战课程(10)-入库功能...(04.08)
- Access快速开发平台--Fun...(04.07)
- 仓库管理实战课程(9)-开发往来单...(04.02)