# DllCall() question with scanner function

## Recommended Posts

Ok, so this is my first attempt at DllCall(), other than the HelpFile example. I have a DLL im trying to read for some hardware that i use.

For the DllCall("dll", ...,....) can i put the full path to the dll if its not located in the sys32 folder?

Below is the documentation for that particular function, which i find with DLL Export viewer. I am uncertain what im suppose to be using for the "return type" - "function" - "parameters"

Any help would be appreciated. I have DllCall("C:\Program Files (x86)\ScanX.dll", "dword", "_CSSNLib::ScanToFileEx") but that is obviously not working for me.

ScanToFileEx

Format

ScanToFileEx(fileName As String) As Long

Parameters

[in] fileName – Null terminated string that holds destination bitmap file name.

Return Value

If function succeeds, the return value is SLIB_ERR_NONE

If function fails, the return number is may be one of the following:

SLIB_ERR_SCANNER_NOT_FOUND – No attached scanner was found.

SLIB_ERR_SCANNER_GENERAL_FAIL

SLIB_ERR_SCANNER_NOT_FOUND

SLIB_ERR_HARDWARE_ERROR

SLIB_ERR_PAPER_FED_ERROR

SLIB_ERR_SCANABORT

SLIB_ERR_NO_PAPER

SLIB_ERR_PAPER_JAM

SLIB_ERR_FILE_IO_ERROR

SLIB_ERR_PRINTER_PORT_USED

SLIB_ERR_OUT_OF_MEMORY

Description

This function works identically to ScanBmpFile, and in addition, the function displays a modal

progress bar while the scan is in progress.

Edited by chachew

##### Share on other sites

I'm no DllCall whizzkid but at a guess (just to give you a rough Idea)

Yes you can define the path to dll, but maybe it needs registering

"ScanToFileEx(fileName As String) As Long" suggets the return type of the function is a Long, which could translate as int if you wish in AutoIt.

It also suggests that it takes just one parameter ,a string which is the path to a bitmap filename.

Its also possible (without full docs) that its in parameter could also be its out parameter (by ref) and is actually working on the file you provide.

Don't take this as true, like I say It's an educated guess.

DllCall("C:\Program Files (x86)\ScanX.dll", "long", "_CSSNLib::ScanToFileEx","str","c:\path\to\bitmap.bmp")

Infact I highly doubt that is correct, as it looks like the function is within a class and you may need to use it as an object type

I've rambled enough.

I'm out.

Monkey's are, like, natures humans.

##### Share on other sites

Thanks for the info, If i do

$dll=DllOpen("C:\Program Files (x86)\ScanX.dll") MsgBox(0,"ScanToFileEX",$dll)

$oOBJ.ScanToFileEX("path") Monkey's are, like, natures humans. #### Share this post ##### Link to post ##### Share on other sites How exactly do i get all the necessary "return types" of various DLL variables that i am trying to access? Is that something that the DLL documentation should outline? #### Share this post ##### Link to post ##### Share on other sites Yes. and dll documentation does not come from dll export viewer, it comes from its developer. Monkey's are, like, natures humans. #### Share this post ##### Link to post ##### Share on other sites Crap...i hoped it would be a little easier than that to make this work. So is all the work being done by DllCall? Like in this example "DllCall("user32.dll","int","MessageBoxW","hwnd",0,"wstr","Hello from Dll tutorial!","wstr","Info","uint",0)" I assume ObjCreate is just an easy way to create a reference to that same function for future calls from ObjGet? Edited by chachew #### Share this post ##### Link to post ##### Share on other sites Don't my word for it as final. Monkey's are, like, natures humans. #### Share this post ##### Link to post ##### Share on other sites I had a little look, and what you have there is the documentation http://www.id-reader.com/ftp/applications/sdk/docs/ScanX.pdf Are you trying to make a fake ID? Monkey's are, like, natures humans. #### Share this post ##### Link to post ##### Share on other sites I had a little look, and what you have there is the documentation http://www.id-reader.com/ftp/applications/sdk/docs/ScanX.pdf Are you trying to make a fake ID? NO fake id's! LOL I work for a software company and we utilize these scanners for all of our clients #### Share this post ##### Link to post ##### Share on other sites #AutoIt3Wrapper_UseX64=n$dll=DllOpen("C:\Program Files (x86)\ScanX.dll")
$result=DllCall($dll, "none", "_CSSNLib::CalibrateScanner")
MsgBox(0,"ScanToFile", @error)

Edited by chachew

##### Share on other sites

When i call the function name with the ordinal value, SciTE crashes

##### Share on other sites

This is about as far as i can get

Global $oErrorHandler = ObjEvent("AutoIt.Error","ObjErrorHandler")$oOBJ=ObjCreate("ScanX.CSSNLib")
$oOBJ.InitSlibLibrary("blah blah blah")$oOBJ.CalibrateScanner()
Func ObjErrorHandler()
ConsoleWrite("A COM Error has occured!" & @CRLF & @CRLF & _
"err.description is: " & @TAB & $oErrorHandler.description & @CRLF & _ "err.windescription:" & @TAB &$oErrorHandler & @CRLF & _
"err.number is: " & @TAB & Hex($oErrorHandler.number, 8) & @CRLF & _ "err.lastdllerror is: " & @TAB &$oErrorHandler.lastdllerror & @CRLF & _
"err.scriptline is: " & @TAB & $oErrorHandler.scriptline & @CRLF & _ "err.source is: " & @TAB &$oErrorHandler.source & @CRLF & _
"err.helpfile is: " & @TAB & $oErrorHandler.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB &$oErrorHandler.helpcontext & @CRLF _
)
EndFunc

##### Share on other sites

Looks like you are making good progress to me, and the results are?

Monkey's are, like, natures humans.

##### Share on other sites

Looks like you are making good progress to me, and the results are?

Errors out..

: ==> The requested action with this object has failed.:
$oOBJ.InitSlibLibrary("blah blah blah")$oOBJ.InitSlibLibrary("blah blah blah")^ ERROR
->15:49:54 AutoIT3.exe ended.rc:1

##### Share on other sites

You might want to check your PC for available objects, it might give you an idea about the syntax, or at least its name.

Once again (and I know I'm not much use to you here) but there is an app you can use for that, I tried it after reading a post here

Might be ole viewer or something and might even be sitting on your system.

EDIT:

Did you successfully register the dll file?

If not you are flogging a dead horse, unless of course its already registered by software installed.

Edited by JohnOne

Monkey's are, like, natures humans.

##### Share on other sites

The file IS registered by an app plus i have manually registered it to make sure that was not the problem. I feel like im missing something in the file to make it work. /frustrating

##### Share on other sites

OK, i finally got it to work. I found out that the driver for the scanner i was using was not working correctly. Reinstalled the drivers and now the DLL function is working as expected!

## Create an account

Register a new account