I'm trying to set up a webcam under IIS on an XP platform. I have the code
below
(purloined from Microsoft's website) in my ASP page. All works fine, for
about four or five
page impressions, then the script fails with error '80210006' /webcam.asp,
line 43 (the "Connect")
If I stop (the stop fails, but the service gets marked as stopped) and
restart the WIA service,
the script works again (for about another 4-5 page impressions).
Can anybody tell me what I'm doing wrong here?
Thanks
John
(Email is spamtrapped - remove "ospam" to reply)
<%@ Language=VBScript %>
<!-- 94A0E92D-43C0-494E-AC29-FD45948A5221 -->
<!--METADATA TYPE="TypeLib" UUID="94A0E92D-43C0-494E-AC29-FD45948A5221"-->
<%
Response.Flush ()
Dim oImage
Dim oDeviceManager
Dim oDeviceInfo
Dim oDevice
Dim oItem
Dim oVector
Set oDeviceManager = Server.CreateObject("WIA.DeviceManager")
For Each oDeviceInfo In oDeviceManager.DeviceInfos
If oDeviceInfo.Type = VideoDeviceType Then
Set oDevice = oDeviceInfo.Connect
Exit For
End If
Next
If oDevice Is Nothing Then
Response.Write "There is no Video Device"
Response.End
End If
Set oItem = oDevice.ExecuteCommand(wiaCommandTakePicture)
Set oImage = oItem.Transfer
Set oVector = oImage.FileData
Set oItem = oDevice.ExecuteCommand(wiaCommandDeleteAllItems)
SaveBinaryData "c:\Inetpub\wwwroot\images\Webcam\pic.bmp",
oVector.BinaryData
' Response.BinaryWrite oVector.BinaryData
Set oDeviceInfo = Nothing
Set oDevice = Nothing
Set oDeviceManager = Nothing
Function SaveBinaryData(FileName, ByteArray)
Const adTypeBinary = 1
Const adSaveCreateOverWrite = 2
'Create Stream object
Dim BinaryStream
Set BinaryStream = CreateObject("ADODB.Stream")
'Specify stream type - we want To save binary data.
BinaryStream.Type = adTypeBinary
'Open the stream And write binary data To the object
BinaryStream.Open
BinaryStream.Write ByteArray
'Save binary data To disk
BinaryStream.SaveToFile FileName, adSaveCreateOverWrite
End Function
%>