Access交流中心

北京 | 上海 | 天津 | 重庆 | 广州 | 深圳 | 珠海 | 汕头 | 佛山 | 中山 | 东莞 | 南京 | 苏州 | 无锡 | 常州 | 南通 | 扬州 | 徐州 | 杭州 | 温州 | 宁波 | 台州 | 福州 | 厦门 | 泉州 | 龙岩 | 合肥 | 芜湖 | 成都 | 遂宁 | 长沙 | 株洲 | 湘潭 | 武汉 | 南昌 | 济南 | 青岛 | 烟台 | 潍坊 | 淄博 | 济宁 | 太原 | 郑州 | 石家庄 | 保定 | 唐山 | 西安 | 大连 | 沈阳 | 长春 | 昆明 | 兰州 | 哈尔滨 | 佳木斯 | 南宁 | 桂林 | 海口 | 贵阳 | 西宁 | 乌鲁木齐 | 包头 |

照相问题

虽虽TV  发表于:2011-10-05 20:47:22  
复制

前几天看到一个社保系统,信息录入窗体中有个“拍照”按钮,并且能完照片的预览、拍照、命名和保存。由于文件较大,无法在此上传附件,所以只能截图上传。

我也想学习学习这个功能,所以请老师们帮忙!跪谢!

 

Top
dbaseIIIer 发表于:2011-10-06 01:34:11

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) 错误!"

 

 

 

 



虽虽TV 发表于:2011-10-06 11:40:50

非常感谢dbaseIIIer!可是我现在的系统是WIN 7,怎么才能在WIN7里运行呢!



总记录:2篇  页次:1/1 9 1 :