Jump to content

Get Default Source or list device with TWAIN DLL


cdeb
 Share

Recommended Posts

I'm trying to verify which is the default scanner and if it is different from what I need to propose a choice among those available.

All this is possible with eztw32.dll however I can not make certain functions work

Are these:

int TWAIN_GetDefaultSourceName(LPSTR pzName)
string TWAIN_DefaultSourceName()

int TWAIN_GetSourceList(void)
source: http://www.eztwain.com/pub/eztp/EZTwain_User_Guide.pdf

I tried this way but they do not work:

Local $pzName
$pzName = DllCall($pathDLL,"int","TWAIN_DefaultSourceName") ;
$rc = DllCall($pathDLL,"int","TWAIN_GetDefaultSourceName", "str*", $pzName) ;
$rc = DllCall($pathDLL,"int","TWAIN_GetDefaultSourceName","str", $pzName) ;
$rc = DllCall($pathDLL,"int","TWAIN_GetSourceList")
$rc = DllCall($pathDLL,"int","TWAIN_GetSourceList", "NONE", "") ;

 

Can anyone help me?

Everything else works, here is the code:

 

Local $pathDLL = @ScriptDir&"\_res\eztw32.dll"

    Local $rc = DllCall($pathDLL,'int','TWAIN_EasyVersion')
    if @error <> 0 then
        MsgBox(16+262144, "DllCall Error", "Error load eztw32.dll")
    else
        ConsoleWrite('--> eztw32.dll version: ' & $rc[0]/100 & @CRLF)
        $rc = DllCall($pathDLL,"int","TWAIN_IsAvailable")
        If @error > 0 Then MsgBox(16+262144, "DllCall Error", "Error call DLL - TWAIN_IsAvailable")

        if $rc[0] <> 0 then
            ConsoleWrite('--> TWAIN available: RC = ' & $rc[0]&@CRLF)

            ;;;;;;;;;;;;;;;;;;;;;; I NEED HERE

            ;manual select scanner
            Local $hwnd
            $rc = DllCall($pathDLL,"long","TWAIN_SelectImageSource",'hwnd',$hwnd)
            ConsoleWrite('--> TWAIN_SelectImageSource = ' & $rc[0]&@CRLF)
            if $rc[0] <> 0 then
                ConsoleWrite("--> TWAIN device selected"&@CRLF)
            else
                ConsoleWrite("--> no TWAIN device selected"&@CRLF)
            endif


        Else
            ConsoleWrite('--> TWAIN NOT available: RC = ' & $rc[0]&@CRLF) ; es: 0
        endif

    endif

thank you

Edited by cdeb
Link to comment
Share on other sites

Try this:

Global $hEZTwain32 = DllOpen(@ScriptDir & "\_res\eztw32.dll")


Local $aCall=0

$aCall=DllCall($hEZTwain32,"str","TWAIN_DefaultSourceName")
;~ $aCall[0] will store returned SourceName

$aCall=DllCall($hEZTwain32,"int","TWAIN_GetDefaultSourceName","str*",0)
;~ $aCall[1] will store returned SourceName

$aCall=DllCall($hEZTwain32,"int","TWAIN_GetSourceList")
;~ $aCall[0] source list


DllClose($hEZTwain32)

Saludos

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...