PDA

Click to See Complete Forum and Search --> : REALLY COMPLEX PROBLEM


chema0377
Aug 1st, 2000, 07:31 PM
I have this structure

typedef struct tag_CMD
{
LPBYTE Command; /* Pointer to an array */
BYTE Status[2];
LPBYTE Data; /* Pointer to an array */
BYTE DataSize;
} CMD;

and it is used in the program as follows

CMD cmdC;
BYTE Cmdd[3];
Cmdd[0] = 0x00;
Cmdd[1] = 0xA4;
Cmdd[2] = 0x00;
Cmdd[3] = 0x00;
BYTE strData[2];
strData[0] = 0x02;
strData[1] = 0x3F;
strData[2] = 0x00;

cmdC.Command = Cmdd;
cmdC.Data = strData;
cmdC.DataSize = 11;

a = CardSendCommand(1,&cmdC);

and in C/C++ works fine, but i have to pass it to VB in order to get the VB programmers on the hip

so, the declaration in C for CardSendCommand is

#define LPCMD CMD far*

SWORD CardSendCommand(BYTE _idCard,LPCMD _cmd)

then in Visual Basic i declare as follows

private type ArrCommand
CLA as Byte
INS as Byte
P1 as Byte
P2 as Byte
end type

private type ArrData
Data1 as Byte
Data2 as Byte
Data3 as Byte
end type

private type S_CMD
Command as ArrCommand
Status(2) as Byte
Data as ArrData
DataSize as Byte
end type

private declare function CardSendCommand Lib _
"XXX" (byval idCard as byte,CMD as S_CMD)

private sub form_load()
dim CMD_T as S_CMD
CMD_T.Command.CLA = 0
CMD_T.Command.INS = &hA4
CMD_T.Command.P1 = 0
CMD_T.Command.P2 = 0
CMD_T.Data.Data1 = 2
CMD_T.Data.Data2 = &H3F
CMD_T.Data.Data3 = 0
CMD_T.DataSize = Len(CMD_T)
debug.print CardSendCommand(1,CMD_T)
end sub

When it gets to the instruction, the program fails and windows crashes, PLEASE HELP !!!!!!!!!!!!!!!