与wia和vb.net的异常为0x80004002

时间:2014-01-13 14:15:42

标签: vb.net exception wia

希望有人可以帮助解决上述错误。

我有以下代码可以正常使用windows xp和柯达scanmate 1120

 Private Sub BtnScan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnScan.Click
    Dim img As WIA.ImageFile = Nothing
    Dim wiaDialog As WIA.CommonDialog = New WIA.CommonDialog
    Dim wiaScanner As WIA.Device
    Dim root As String = "c:\myimages"
    Dim IFileName As String = TxtInvoiceNo.Text
    Dim WiaCommonDialog As New WIA.CommonDialog

    If TxtInvoiceNo.Text = "" Then
        'FrmPicDisplay.Show()
        MsgBox("Please enter a valid Invoice No." & vbNewLine _
           & "Then press scan button to continue.")
        TxtInvoiceNo.Select()

    ElseIf My.Computer.FileSystem.FileExists(root & IFileName & ".bmp") Then
        MsgBox("This filename already exists," & vbNewLine _
            & "Please enter a different filename")
        TxtInvoiceNo.Text = ""
    Else
        Ino = TxtInvoiceNo.Text
        wiaScanner = wiaDialog.ShowSelectDevice
        With wiaScanner.Items(1)
            .Properties("6146").Value = 4 '4 is Black-white,gray is 2, color 1 (Color Intent)
            .Properties("6147").Value = 200 'dots per inch/horizontal
            .Properties("6148").Value = 200 'dots per inch/vertical
            .Transfer(wiaFormatTIFF) '("{B96B3CAB-0728-11D3-9D7B-0000F81EF32E}") 'BMP format - This prompts the scan
        End With


        img = wiaScanner
        Dim Item As WIA.Item = TryCast(wiaScanner.Items(1), WIA.Item)
        Dim imageBytes As [Byte]() = DirectCast(img.FileData.BinaryData, Byte())
        Dim ms As New MemoryStream(imageBytes)
        Dim image_1 As Image = Image.FromStream(ms)


        img.SaveFile("c:\myimages" & TxtInvoiceNo.Text & ".bmp")

我不得不将电脑更改为Windows 7,现在程序无法正常工作,并在行中给出了上述错误

 img = wiaScanner

通过搜索它我发现它听起来像一个com异常,但我真的不明白从哪里开始寻找所以任何帮助都会非常感激。

由于           加雷

0 个答案:

没有答案