Link to home
Start Free TrialLog in
Avatar of HASANDIZ
HASANDIZ

asked on

How can I get the list of TWAIN Devices vb.net

I have a xKube Lottery Printer Scanner, how can I connect to that scanner so I can scan a slip and save it as picture file. I am not sure where to start. Pls help
Avatar of Daniel Van Der Werken
Daniel Van Der Werken
Flag of United States of America image

What you're looking for is ".net interop twain" and here is a decent search result:
http://www.codeproject.com/Articles/1376/NET-TWAIN-image-scanner

Which is likely the best solution out there. Good luck!
Avatar of HASANDIZ
HASANDIZ

ASKER

I have this dll that I have to use but cannot use it since I have WIN7 x64 keep saying cant use it. How can i add within the code instead of preferences so I can use that dll ? Delphi code is something like this

  function VbCePrnInitCeUsbSI(var dwSysErr: Integer): Integer; stdcall; external 'CeSmLm.dll';

but I need to convert that to VB.net 2008

Thanks again
Is it a COM DLL?
no, it came with the printer xKube driver. When I try to add as comm I couldnt. I am going to try this and see if it works



    <DllImport("sss.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
 
    Shared Function GetWindowText(ByVal hwnd As IntPtr, _
 
                       ByVal lpString As StringBuilder, _
 
                       ByVal cch As Integer) As Integer
 
    End Function
ASKER CERTIFIED SOLUTION
Avatar of Daniel Van Der Werken
Daniel Van Der Werken
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Ok I got the compile running but still dont get the program to connect I believe. I have imported the dll like

    <DllImport("cesmlm.dll", CallingConvention:=CallingConvention.StdCall)> Shared Function VbCePrnGetInterfaceNumUsb(ByRef prnName As String, ByRef dwApp As Integer) As Integer
    End Function

Open in new window


and call it like this

            RichTextBox1.Text &= vbNewLine & "Entering InitUsbLayerSw ..."

            Dim dwInt As Integer
            Dim dwErr As Integer
            Dim dwApp As Integer
            Dim a As Integer

            dwInt = VbCePrnInitCeUsbSI(dwErr)

            If dwErr <> 0 Then
                RichTextBox1.Text &= vbNewLine & "dwErr Error...    dwErr <> 0"
                Return False
            ElseIf dwInt > 0 Then
                RichTextBox1.Text &= vbNewLine & "dwInt > 0 ....   dwInt:" & dwInt
                a = VbCePrnGetInterfaceNumUsb(m_strPrnName, dwApp)

                If dwApp = 127 Then
                    RichTextBox1.Text &= vbNewLine & "InitUSBLayer Done With Error...   dwApp = 127 Error"
                    Return False
                Else
                    m_intDevSel = dwApp
                    RichTextBox1.Text &= vbNewLine & "m_strPrnName := " & m_strPrnName
                    RichTextBox1.Text &= vbNewLine & "InitUSBLayer Done ..."
                    Return True
                End If
            End If

            RichTextBox1.Text &= vbNewLine & "InitUSBLayer Done ..."

Open in new window


I know I should not get the dwApp= 127 but I do. I have no idea what are the return codes and cannot find any info on the returns on these dll functions.

Any Idea?

Thanks