Home > database >  Pb call c API, structure type conversion problem
Pb call c API, structure type conversion problem

Time:09-18

Read the second generation id card information, the main possible type conversion problems haven't been solved
Vc inside definition:
Int GetPersonIDNo (char * IDNo, char * ErrMsg)
Int GetPersonMsgA (PERSONINFO * PersonMsg, char * ErrMsg);
Int GetPersonMsg (PERSONINFO * PersonMsg, char * ImageFile, char * ErrMsg)
Typedef struct _personinfoa
{
Char name [32].
Char sex [4];
Char nation [20].
Char birthday [12].
Char address [72].
Char cardId [20].
Char police [32].
Char validStart [12].
Char validEnd [12].
Char sexCode [4].
Char nationCode [4].
Char appendMsg [72].
} PERSONINFOA, * PPERSONINFOA;
Pb defined in
The Function int GetPersonMsgA (ref str_PERSONINFO PersonMsg, ref string ErrMsg) LIBRARY "LKE_SiCard. DLL
"The Function int GetPersonMsg (ref str_PERSONINFO PersonMsg, string ImageFile, ref string ErrMsg) LIBRARY "LKE_SiCard. DLL
"The Function int GetPersonIDNo (ref string IDNo, ref string ErrMsg) LIBRARY "LKE_SiCard. DLL
"
A function call
Int i_ret
String str_errmsg str_CardNo, szFile, str_IDNo
Str_personinfo str_str_personinfo1

Str_errmsg=space (256)
Str_CardNo=space (128)
Str_IDNo=space (128)
SzFile=space (260)
SzFile="IDPhoto. BMP"
Str_str_personinfo1. Name=space (32)
Str_str_personinfo1. Sex=space (4)
Str_str_personinfo1. Nation=space (20)
Str_str_personinfo1. Birthday=space (12)
Str_str_personinfo1. Address=space (72)
Str_str_personinfo1. CardId=space (20)
Str_str_personinfo1. Police=space (32)
Str_str_personinfo1. ValidStart=space (12)
Str_str_personinfo1. ValidEnd=space (12)
Str_str_personinfo1. SexCode=space (4)
Str_str_personinfo1. NationCode=space (4)
Str_str_personinfo1. AppendMsg=space (72)

I_ret=OpenPort (str_errmsg)
If i_ret=0 then
I_ret=GetPersonMsg (str_str_personinfo1 szFile, str_errmsg)
I_ret=GetPersonMsgA (str_str_personinfo1 str_errmsg)
I_ret=GetPersonIDNo (str_IDNo str_ErrMsg)
The else
Messagebox (' ', str_errmsg)
End the if
The three calls to an error, the first is the function of internal pictures, speaking, reading and writing, the second is to remove the write photos, directly take information,
Results in the second and the third is an error, type of what I have to check, char * corresponding to the string, and allocate the size in advance, don't know what problem, ask ace to give directions!

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
The original concept Application Execution Error (R0021)
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
The Application terminated.

Error: Bad runtime function reference at line 33 clicked in the event of object cb_5 of w_cx.
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Sure
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

CodePudding user response:

Through pass by don't miss the opportunity, please guide XDJM

CodePudding user response:

http://bbs.csdn.net/topics/310238887 under reference!
  • Related