I'm trying to print to a Zebra printer (p430i) from within VB6. I also need to encode mifare cards with this printer. All of the documentation and sample code for the mifare functionality is written in C++.
I am trying to convert this code to VB6.
This is what I have.
This is the code I use to call it:
I have this code in a regular bas module. There are other dll functions that I call (which work). When I try to call this function, I don't get any run time errors but I do get an error.
The last parameter to the function is err. After calling the function, the err value is 63 which translates to invalid parameter.
I've been struggling and googling, but can't seem to get it right.
-George
Microsoft SQL Server MVP
My Blogs
SQLCop
twitter
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
I am trying to convert this code to VB6.
Code:
typedef struct S_CARD_AND_TIMEOUT
{
unsigned char ucCard;
unsigned char ucIsTimeoutSpecified;
unsigned char ucTimeout_50msBased;
}sCARD_AND_TIMEOUT;
typedef struct S_GET_CARD_A
{
/* IN: Size of the following buffer */
/* OUT: Serial Number length */
int iSerialNumberSize;
/* Can be from 1 to 3 Cascade Level */
unsigned char *pucSerialNumber;
unsigned short usATQA;
unsigned char ucSAK;
}sGET_CARD_A;
typedef int (CALLBACK *ZBRMF_ISO14443_3_A_GetCard)(HANDLE hPrinter, int printerType, sCARD_AND_TIMEOUT* cardAndTimeout, sGET_CARD_A* getCardAInfo, int* err);
Code:
// Timeout and Card Management Struct Definitions
sCARD_AND_TIMEOUT cardAndTimeout; // Card And Timeout Structure
memset(&cardAndTimeout, 0, sizeof(cardAndTimeout));
cardAndTimeout.ucIsTimeoutSpecified = 0x01; // Timeout specified
cardAndTimeout.ucTimeout_50msBased = 0x3C; // Timeout value (~3 seconds)
cardAndTimeout.ucCard = 0x00; // First Card
// Card Target is the first ISO14443A Card Found in Field
sGET_CARD_A getCardA; // Card A Info Structure
memset(&getCardA, 0, sizeof(getCardA));
unsigned char serialNumberA[10]; // Three cascade level length
getCardA.pucSerialNumber = serialNumberA;
getCardA.iSerialNumberSize = sizeof(serialNumberA);
// Get ISO14443 A Card
/* Performs the following sequence of commands
- RF Reset
- Request A
- Anticollision
- Select
*/
err = zsdkISO14443_3_A_GetCard(hPrinter, printerType, &cardAndTimeout, &getCardA, &error);
if ((!err || error) != ZBR_ERROR_NO_ERROR)
{
printf("\n\nISO14443_3_A_GetCard Failed");
throw error;
}
This is what I have.
Code:
Public Type S_CARD_AND_TIMEOUT
ucCard As Byte
ucIsTimeoutSpecified As Byte
ucTimeout_50msBased As Byte
End Type
Public Type S_GET_CARD_A
'/* IN: Size of the following buffer */
'/* OUT: Serial Number length */
iSerialNumberSize As Long
'/* Can be from 1 to 3 Cascade Level */
pucSerialNumber As Byte
usATQA As Long
ucSAK As Byte
End Type
Public Declare Function ZBRGPMF_ISO14443_3_A_GetCard _
Lib "ZBRGPMF" ( _
ByVal hPrinter As Long, _
ByVal PrinterType As Long, _
ByRef cardAndTimeout As S_CARD_AND_TIMEOUT, _
ByRef getCardAInfo As S_GET_CARD_A, _
ByRef err As Long) _
As Long
This is the code I use to call it:
Code:
Dim ReturnValue As Long
Dim Error As Long
Dim ErrorMessage As String
Dim CardType As Byte
Dim i As Long
'
' // Timeout and Card Management Struct Definitions
'// Card And Timeout Structure
' ucIsTimeoutSpecified -- Timeout specified
' ucTimeout_50msBased -- Timeout value (~3 seconds)
' // First Card
Dim cardAndTimeout As S_CARD_AND_TIMEOUT
' memset(&cardAndTimeout, 0, sizeof(cardAndTimeout));
cardAndTimeout.ucIsTimeoutSpecified = &H1
cardAndTimeout.ucTimeout_50msBased = &H3C
cardAndTimeout.ucCard = &H0
' // Card Target is the first ISO14443A Card Found in Field
'; // Card A Info Structure
'; // Three cascade level length
Dim getCardA As S_GET_CARD_A
' memset(&getCardA, 0, sizeof(getCardA));
'
Dim serialNumberA(9) As Byte
'getCardA.pucSerialNumber = serialNumberA
getCardA.iSerialNumberSize = UBound(serialNumberA) + 1
' // Get ISO14443 A Card
' /* Performs the following sequence of commands
' - RF Reset
' - Request A
' - Anticollision
' - Select
' */
ReturnValue = ZBRGPMF_ISO14443_3_A_GetCard(hPrinter, printerType, cardAndTimeout, getCardA, Error)
[!]' ReturnValue = 0[/!]
If Error <> ZBR_ERROR_NO_ERROR Then
[!]' The Error variable is 63[/!]
ErrorMessage = TranslateError(Error)
GoTo OSIErrorHandler
End If
I have this code in a regular bas module. There are other dll functions that I call (which work). When I try to call this function, I don't get any run time errors but I do get an error.
The last parameter to the function is err. After calling the function, the err value is 63 which translates to invalid parameter.
I've been struggling and googling, but can't seem to get it right.
-George
Microsoft SQL Server MVP
My Blogs
SQLCop
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom