B
Bob Yang
Hi, I have this in C++ and I like to call it from c# to get the value
but I fail. it will be good if you can give me some information. I
tried it in VB.net it works but I use almost the same way as VB in C#
but it doens't work.
c++: (csp2.dll)
NoMangle long DLL_IMPORT_EXPORT csp2TimeStamp2Str(unsigned char
*Stamp, char *value, long nMaxLength);
VB.net: (this works correctly)
Declare Function csp2TimeStamp2Str Lib "csp2.dll" (ByRef Stamp As
Byte, ByVal value As String, ByVal nMaxLength As Integer) As Integer
Dim nRC As Integer
Dim arrbyteBarcode(99) As Byte '100 elements
Dim nBytesRead As Integer
Dim bstrTmp As New VB6.FixedLengthString(50)
nBytesRead = csp2GetPacket(arrbyteBarcode(0), i, 100)
nRC = csp2TimeStamp2Str(arrbyteBarcode(nBytesRead - 4), bstrTmp.Value,
Len(bstrTmp.Value))
TextBox1.text= VB.Left(bstrTmp.Value, 20)
C#: (this doesn't work )
[System.Runtime.InteropServices.DllImport("csp2.DLL")] static extern
int csp2TimeStamp2Str(byte value, string Stamp, int nMaxLength);
int nRC, nBytesRead;
byte[] arrbyteBarcode= new byte[100];
FixedLengthString bstrTmp = new FixedLengthString(50);
nBytesRead = csp2GetPacket(arrbyteBarcode[0], i, 100);
bstrTmp=" ";
nRC = csp2TimeStamp2Str(arrbyteBarcode[nBytesRead-4],
bstrTmp.Value, bstrTmp.Value.Length);
TextBox1.text= bstrTmp.Value.toString();
but I fail. it will be good if you can give me some information. I
tried it in VB.net it works but I use almost the same way as VB in C#
but it doens't work.
c++: (csp2.dll)
NoMangle long DLL_IMPORT_EXPORT csp2TimeStamp2Str(unsigned char
*Stamp, char *value, long nMaxLength);
VB.net: (this works correctly)
Declare Function csp2TimeStamp2Str Lib "csp2.dll" (ByRef Stamp As
Byte, ByVal value As String, ByVal nMaxLength As Integer) As Integer
Dim nRC As Integer
Dim arrbyteBarcode(99) As Byte '100 elements
Dim nBytesRead As Integer
Dim bstrTmp As New VB6.FixedLengthString(50)
nBytesRead = csp2GetPacket(arrbyteBarcode(0), i, 100)
nRC = csp2TimeStamp2Str(arrbyteBarcode(nBytesRead - 4), bstrTmp.Value,
Len(bstrTmp.Value))
TextBox1.text= VB.Left(bstrTmp.Value, 20)
C#: (this doesn't work )
[System.Runtime.InteropServices.DllImport("csp2.DLL")] static extern
int csp2TimeStamp2Str(byte value, string Stamp, int nMaxLength);
int nRC, nBytesRead;
byte[] arrbyteBarcode= new byte[100];
FixedLengthString bstrTmp = new FixedLengthString(50);
nBytesRead = csp2GetPacket(arrbyteBarcode[0], i, 100);
bstrTmp=" ";
nRC = csp2TimeStamp2Str(arrbyteBarcode[nBytesRead-4],
bstrTmp.Value, bstrTmp.Value.Length);
TextBox1.text= bstrTmp.Value.toString();