Vb.net visualbasic与Twain应用
你好,我有一个小的vb知识,所以请帮助我。当我运行可以访问扫描仪的程序时,出现错误“AccessViolationException未处理”“试图读取或写入受保护内存。这通常表示其他内存已损坏。” 这是我的密码:Vb.net visualbasic与Twain应用,vb.net,visual-studio-2015,Vb.net,Visual Studio 2015,你好,我有一个小的vb知识,所以请帮助我。当我运行可以访问扫描仪的程序时,出现错误“AccessViolationException未处理”“试图读取或写入受保护内存。这通常表示其他内存已损坏。” 这是我的密码: Public Sub CloseSource() Try Dim rc As TwRC If Not Equals(SelectedDataSource.Id, IntPtr.Zero) Then
Public Sub CloseSource()
Try
Dim rc As TwRC
If Not Equals(SelectedDataSource.Id, IntPtr.Zero) Then
Dim guif As TwUserInterface = New TwUserInterface()
' tell the data source to disable its user interface
rc = DS_Userif(appid, SelectedDataSource, TwDG.TwDG_Control, TwDAT.TwDAT_UserInterface, TwMSG.TwMSG_DisableDS, guif)
' tell the device manager to release the source
rc = DSM_Ident(appid, IntPtr.Zero, TwDG.TwDG_Control, TwDAT.TwDAT_Identity, TwMSG.TwMSG_CloseDS, SelectedDataSource)
' set the pointer to zero
SelectedDataSource.Id = IntPtr.Zero
End If
Catch ex As Exception
End Try
End Sub
从您的信息和代码中,我了解到您在关闭扫描仪时出现异常。我认为您有例外,因为扫描仪尚未准备好关闭。请确保扫描仪处于正确状态并且可以关闭 致以最诚挚的问候,Alexander
公共类TW_用户界面
<StructLayout(LayoutKind.Sequential, Pack:=2)> Public Class TW_USERINTERFACE
Public ShowUI As Short ' TW_BOOL
Public ModalUI As Short ' TW_BOOL
Public hParent As UInt32 ' TW_HANDLE
End Class
公共ShowUI简称“TW_BOOL”
公共ModalUI简称“TW_BOOL”
公共场所如UInt32'TW_手柄
末级
不幸的是,bool是4字节
所以我们使用short(0=false,1=true)