#194945 - 2009-07-21 04:37 PM
A new DynaWrap try
|
Viggen
Starting to like KiXtart
Registered: 2002-03-22
Posts: 110
|
Hi everyone!
Not long after that Shawn helped me with the BCPwrapper, my boss came along... with another barcode scanner. I told him that he should stick to the first one, but 'he's the boss'  (the new one is a small key-chain thingy...and *it's sooo much cooler* ) 
Anyways... The new scanner came with a much better SDK, so I thought I'd take a look at it, and the dll can't be registered.
Now I'm back at DynaWrap again, and I can contact the scanner, so I know that I have made some progress with it. There is just some things that needs a bit of clarification =)
Here's my test so far: $Port = 15
$dyn = CreateObject("DynamicWrapper")
?? @error
$nul = $dyn.Register("C:\Windows\System\Csp2.dll", "csp2Init", "i=l", "f=s", "r=l")
?? @error
$dOpen = $dyn.csp2Init($Port)
?? @error
$nul = $dyn.Register("C:\Windows\System\Csp2.dll", "csp2DataAvailable","i=l", "f=s", "r=l")
?? @error
debug on
$dDA = $dyn.csp2DataAvailable()
?? @error
? @serror
By changing ports, I have verified that it works as far as opening it, but when I get to the error output after $dDA, I get:
-2147352562 Invalid number of parameters.
I have probably overlooked something, the question is what 
In the SDK I found this: Declare Function csp2Init Lib "csp2.dll" (ByVal nComPort As Long) As Long
Declare Function csp2DataAvailable Lib "csp2.dll" () As Long
So what makes the first one work, and the other not?
/Viggen
|
Top
|
|
|
|
#195038 - 2009-07-25 03:20 PM
Re: A new DynaWrap try
[Re: Arend_]
|
Viggen
Starting to like KiXtart
Registered: 2002-03-22
Posts: 110
|
Ah!
I had a thought about omiting "i", and I tried these: $nul = $dyn.Register("C:\Windows\System\Csp2.dll", "csp2DataAvailable","i=", "f=s", "r=l")
$nul = $dyn.Register("C:\Windows\System\Csp2.dll", "csp2DataAvailable","i=''", "f=s", "r=l")
$nul = $dyn.Register("C:\Windows\System\Csp2.dll", "csp2DataAvailable","", "f=s", "r=l")
$nul = $dyn.Register("C:\Windows\System\Csp2.dll", "csp2DataAvailable",, "f=s", "r=l")
And then I gave up 
I never thought about the "easy one" 
When you wrote "don't include..." it hit me... It shall of course be this:
$nul = $dyn.Register("C:\Windows\System\Csp2.dll", "csp2DataAvailable", "f=s", "r=l")

Thanks for pointing me in the right direction!!
Now I have another problem, and that seems to be the end of this experiment.
Another of the functions in the dll expects a byte-input, and if I'm not totally wrong, kix can't create byte arrays.
/Viggen
******* Edit********
Hmm... found this, but I'm not sure if I can use that to create a byte array of 100 elements... (aiming for something like "Dim bytearray(99) as byte")
Using ADO to convert to / from BYTE arrays
Edited by Viggen (2009-07-25 03:48 PM) Edit Reason:
|
Top
|
|
|
|
#195055 - 2009-07-27 10:50 AM
Re: A new DynaWrap try
[Re: Richard H.]
|
Viggen
Starting to like KiXtart
Registered: 2002-03-22
Posts: 110
|
Oh, ok. 
Thanks!
|
Top
|
|
|
|
#195222 - 2009-08-03 03:28 PM
Re: A new DynaWrap try
[Re: Viggen]
|
Arend_
MM club member
   
Registered: 2005-01-17
Posts: 1896
Loc: Hilversum, The Netherlands
|
Glad you got it to work 
Byte array is possible, look at my UUID2netbootGUID UDF.
|
Top
|
|
|
|
#195372 - 2009-08-10 05:28 PM
Re: A new DynaWrap try
[Re: Arend_]
|
Viggen
Starting to like KiXtart
Registered: 2002-03-22
Posts: 110
|
Hey! Thanks!
I looked at the UDF, and from that I pulled this (which seems to work) 
; ******************************************************
Function ByteArray($array)
Dim $stream, $i
$stream = CreateObject("ADODB.Stream")
If @error
Exit @error
EndIf
$stream.Type = 2
$stream.CharSet = "windows-1252"
$stream.Open
For $i=0 to Ubound($array)
$stream.WriteText(Chr(Val("&"+$array[$i])))
Next
$stream.Position = 0
$stream.Type = 1
$ByteArray = $stream.Read
$stream.Close
Endfunction
; ******************************************************
However I'm stuck at the translation of the vb-code in the form for the scanner. I'll start a new thread since this is now about the code, not DynaWrap.
Thanks again!
/Viggen
The new thread is here...
Edited by Viggen (2009-08-10 05:55 PM) Edit Reason: added link to the new thread
|
Top
|
|
|
|
Moderator: Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart
|
0 registered
and 581 anonymous users online.
|
|
|