hi,
I bought me a symbol CS1504 scanner to use the scanner there is an sdk with
an C++ dll and an example code written in vb6 to bind the dll to the vb6 app.
I got my app running in vb6 but like to rebuild the thing so i can use it in
vb.net.
If I just open the app in visual studio 2005 I get an error and It just
shuts down.
Do i need to convert the C++ dll?
How do I get the DLL to work in vb.net?
The code from VB6:
'// Communications
Declare Function csp2Init Lib "csp2.dll" (ByVal nComPort As Long) As Long
Declare Function csp2Restore Lib "csp2.dll" () As Long
Declare Function csp2WakeUp Lib "csp2.dll" () As Long
Declare Function csp2DataAvailable Lib "csp2.dll" () As Long
'// Basic Functions
Declare Function csp2ReadData Lib "csp2.dll" () As Long
Declare Function csp2ClearData Lib "csp2.dll" () As Long
Declare Function csp2PowerDown Lib "csp2.dll" () As Long
Declare Function csp2GetTime Lib "csp2.dll" (aTimeBuf As Byte) As Long
Declare Function csp2SetTime Lib "csp2.dll" (aTimeBuf As Byte) As Long
Declare Function csp2SetDefaults Lib "csp2.dll" () As Long
'// CSP Data Get
Declare Function csp2GetPacket Lib "csp2.dll" (stPacketData As Byte, ByVal
lgBarcodeNumber As Long, ByVal maxLength As Long) As Long
Declare Function csp2GetDeviceId Lib "csp2.dll" (szDeviceId As Byte, ByVal
nMaxLength As Long) As Long
Declare Function csp2GetProtocol Lib "csp2.dll" () As Long
Declare Function csp2GetSystemStatus Lib "csp2.dll" () As Long
Declare Function csp2GetSwVersion Lib "csp2.dll" (ByVal szSwVersion As
String, ByVal nMaxLength As Long) As Long
Declare Function csp2GetASCIIMode Lib "csp2.dll" () As Long
Declare Function csp2GetRTCMode Lib "csp2.dll" () As Long
'// DLL Configuration
Declare Function csp2SetRetryCount Lib "csp2.dll" (ByVal nRetryCount As
Long) As Long
Declare Function csp2GetRetryCount Lib "csp2.dll" () As Long
'// Miscellaneous
Declare Function csp2GetDllVersion Lib "csp2.dll" (ByVal szDllVersion As
String, ByVal nMaxLength As Long) As Long
Declare Function csp2TimeStamp2Str Lib "csp2.dll" (Stamp As Byte, ByVal
value As String, ByVal nMaxLength As Long) As Long
Declare Function csp2GetCodeType Lib "csp2.dll" (ByVal CodeID As Long, ByVal
CodeType As String, ByVal nMaxLength As Long) As Long
'// Advanced functions
Declare Function csp2ReadRawData Lib "csp2.dll" (aBuffer As Byte, ByVal
nMaxLength As Long) As Long
Declare Function csp2SetParam Lib "csp2.dll" (ByVal nParam As Long, szString
As Byte, ByVal nMaxLength As Long) As Long
Declare Function csp2GetParam Lib "csp2.dll" (ByVal nParam As Long, szString
As Byte, ByVal nMaxLength As Long) As Long
Declare Function csp2Interrogate Lib "csp2.dll" () As Long
Declare Function csp2GetCTS Lib "csp2.dll" () As Long
Declare Function csp2SetDTR Lib "csp2.dll" (ByVal nOnOff As Long) As Long
Declare Function csp2SetDebugMode Lib "csp2.dll" (ByVal nOnOff As Long) As
Long
'// Returned status values...
Global Const STATUS_OK As Long = 0
Global Const COMMUNICATIONS_ERROR As Long = -1
Global Const BAD_PARAM As Long = -2
Global Const SETUP_ERROR As Long = -3
Global Const INVALID_COMMAND_NUMBER As Long = -4
Global Const COMMAND_LRC_ERROR As Long = -7
Global Const RECEIVED_CHARACTER_ERROR As Long = -8
Global Const GENERAL_ERROR As Long = -9
Global Const FILE_NOT_FOUND As Long = 2
Global Const ACCESS_DENIED As Long = 5
'// Parameter values...
Global Const PARAM_OFF As Long = 0
Global Const PARAM_ON As Long = 1
Global Const DATA_AVAILABLE As Long = 1
Global Const DATA_NOT_AVAILABLE As Long = 0
Global Const DETERMINE_SIZE As Long = 0
I have tride to load the dll with te code:
Dim a As Reflection.Assembly
Dim lateBDLL As String
Dim obj As Object
Dim Params() As Object
lateBDLL = "Csp2.dll"
Debug.Print(lateBDLL)
a = Reflection.Assembly.LoadFrom(lateBDLL)
thanks
Ralph - 26 Aug 2007 18:11 GMT
> hi,
>
[quoted text clipped - 8 lines]
> Do i need to convert the C++ dll?
> How do I get the DLL to work in vb.net?
<snipped>
In spite of the original code being in VB6, you will be better off posting
to a dotNet newsgroup. Many people here don't even have dotNet loaded, let
alone use it.
Also the fact you having difficulties with attempting to open a VB6 project
in VB.Net demonstrates you need to understand the differences.
Consider that using VC++/cli it may be possible to do a more direct port.
You can find a complete list of managed (dotNet) newsgroups for help here:
http://msdn.microsoft.com/subscriptions/managednewsgroups/list.aspx
This article outlines the differences between VB Classic and New VB:
http://msdn2.microsoft.com/en-us/library/kehz1dz1(VS.80).aspx
hth
-ralph