Where did I go wrong with calldll32 ?

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
huangchenmin
Posts: 157
Joined: Mon Jun 07, 2010 2:24 am

Where did I go wrong with calldll32 ?

Post by huangchenmin »

Dear all:
i need to call function in CsHis.dll in order to read data from IC card. Followings are parts of coding.
Local m_par02:=3660,m_par01:=space(m_par02),;
m_par03:=1,m_par04:=60,m_par05:=60
m_secStart:=second()
*hisReadPrescriptMain(@m_par01, @m_par02, m_par03 , m_par04 ,@m_par05);
m_ermsg:=calldll32( "hisReadPrescriptMain" , "cshis.dll" ;
,@m_par01,@m_par02,1,60,@m_par05)

Following are reference of CsHis.dll about function hisReadPrescriptMain()
ERRORCODE hisReadPrescriptMain(char *pOutpatientPrescription, int *iBufferLenOutpatient, int iStartPos, int iEndPos,int *iRecCount);
ErrorCode : Error code that hisReadPrescriptMain() returns.
[out]pOutpatientPrescription : data that hisReadPrescriptMain() returns.
[in/out]iBufferLenOutpatient : length of pOutpatientPrescription.
[in]iStartPos : initial position I would like to read in ic card.
[in]iEndPos : end position I would like to read in ic card.
[in/out]*iRecCount: how many number I would to read.

Following are error message in hb_out.log
Application Internal Error - J:\ReadIC\icreader.exe
Terminated at: 2010.12.10 07:26:50
Unrecoverable error 6005: Exception error:

Exception Code:C0000005
Exception Address:10002917
EAX:00000048 EBX:00D22D4C ECX:00000000 EDX:00000000
ESI:0022F355 EDI:0022F391 EBP:0022F4F8
CS:EIP:001B:10002917 SS:ESP:0023:0022F30C
DS:0023 ES:0023 FS:003B GS:0000
Flags:00010246
CS:EIP: 66 83 38 48 66 89 8C 24 92 00 00 00 7E 05 66 C7
SS:ESP: 0022F50C 00000048 74614400 0000000E 00000000 00000000 00000000 A9B70000 0000C1A5 00000000 00000000 00000000 30323143 38383238 36303932 30393030

C stack:
EIP: EBP: Frame: OldEBP, RetAddr, Params...
10002917 0022F4F8 0022F568 004088C1 0053213B 0053214D 00000002 00D22D4C 00000048 00000000 00000000 00000000
004088C1 0022F568 0022F59C 00471A6B 00C4A41C 00C4A57C 00C4A59C 0046506D 00C4A57C 00C4A59C 00000002 0000000B


Modules:
0x00400000 0x001CF000 J:\ReadIC\icreader.exe
0x7C920000 0x00094000 C:\WINDOWS\system32\ntdll.dll
0x7C800000 0x0011F000 C:\WINDOWS\system32\kernel32.dll
0x77DA0000 0x000A7000 C:\WINDOWS\system32\ADVAPI32.DLL
0x77E50000 0x00092000 C:\WINDOWS\system32\RPCRT4.dll
0x77FC0000 0x00011000 C:\WINDOWS\system32\Secur32.dll
0x77180000 0x00103000 C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.5512_x-ww_35d4ce83\COMCTL32.DLL
0x77BE0000 0x00058000 C:\WINDOWS\system32\msvcrt.dll
0x77EF0000 0x00049000 C:\WINDOWS\system32\GDI32.dll
0x77D10000 0x0008F000 C:\WINDOWS\system32\USER32.dll
0x77F40000 0x00076000 C:\WINDOWS\system32\SHLWAPI.dll
0x76320000 0x00047000 C:\WINDOWS\system32\COMDLG32.DLL
0x7D590000 0x007F5000 C:\WINDOWS\system32\SHELL32.dll
0x73B40000 0x00020000 C:\WINDOWS\system32\MSVFW32.DLL
0x76B10000 0x0002A000 C:\WINDOWS\system32\WINMM.dll
0x76990000 0x0013D000 C:\WINDOWS\system32\OLE32.dll
0x770F0000 0x0008B000 C:\WINDOWS\system32\OLEAUT32.DLL
0x72F70000 0x00026000 C:\WINDOWS\system32\WINSPOOL.DRV
0x76300000 0x0001D000 C:\WINDOWS\system32\IMM32.DLL
0x621F0000 0x00009000 C:\WINDOWS\system32\LPK.DLL
0x73FA0000 0x0006B000 C:\WINDOWS\system32\USP10.dll
0x5A410000 0x00037000 C:\WINDOWS\system32\uxtheme.dll
0x74680000 0x0004C000 C:\WINDOWS\system32\MSCTF.dll
0x73640000 0x0002E000 C:\WINDOWS\system32\msctfime.ime
0x10000000 0x001E3000 J:\ReadIC\CsHis.dll
0x71A10000 0x00017000 C:\WINDOWS\system32\WS2_32.dll
0x71A00000 0x00008000 C:\WINDOWS\system32\WS2HELP.dll
0x00F80000 0x00009000 J:\ReadIC\HCAUtility.dll
0x010A0000 0x00013000 J:\ReadIC\Reader.dll

Called from HB_DYNACALL1(0)
Called from CALLDLL32(7930) in c:/hmg/source/h_controlmisc.prg
Called from R_PI(154) in icreader.prg
Called from COM_INIT(115) in icreader.prg
Called from (b)MAIN(27) in icreader.prg
Called from _PROCESSINITPROCEDURE(5082) in c:/hmg/source/h_windows.prg
Called from _ACTIVATEWINDOW(4838) in c:/hmg/source/h_windows.prg
Called from MAIN(102) in icreader.prg
------------------------------------------------------------------------

:roll: :? Where did I go wrong ?
Plase Help!
Best Regards!
Attachments
ReadIC.rar
(118.02 KiB) Downloaded 189 times
User avatar
dhaine_adp
Posts: 457
Joined: Wed Aug 06, 2008 12:22 pm
Location: Manila, Philippines

Re: Where did I go wrong with calldll32 ?

Post by dhaine_adp »

Hi,

To get a clue please check what h_contromisc.prg is doing on line 7930, is it doing str() on it or trim, etc. Cx05 problem is a generic error trapping. So it follows that before you attempt to read the data, make sure that the connection to comm port and reader is well established meaning a handshake and carrier is detected by the computer.

If you have hypertimal, procomm or other communication program, verify (interrogate) the connecvity if you can manually read from the comm port. Please make sure that you set the correct speed (baud rate), parrity, etc. In Ubuntu, you can use minicom.

I'm sorry friend, I cannot provide further details on the problem but I hope somehow it helps. Anyway I also put a link here that I found on the net. Here it is: http://www.windowsbbs.com/windows-2000/ ... ation.html

Regards,

Danny
Regards,

Danny
Manila, Philippines
huangchenmin
Posts: 157
Joined: Mon Jun 07, 2010 2:24 am

Re: Where did I go wrong with calldll32 ?

Post by huangchenmin »

dhaine_adp wrote:Hi,

To get a clue please check what h_contromisc.prg is doing on line 7930, is it doing str() on it ........
Regards,
Danny
Dear Danny
Thanks for your supports.
There is another function in CSHIS.DLL named hisGetBasicData.
ERRORCODE=hisGetBasicData(char *pBuffer, int *iBufferLen)
I call hisGetBasicData as reference said and error message return as attachment.
Then I modify my code as following and works.
Local m_par01:=space(72),m_par02:=72
m_ermsg:=calldll32( "hisGetBasicData","CsHis.dll",m_par01,space(72),m_par02)

Best Regards
Attachments
hb_out.rar
(1.11 KiB) Downloaded 202 times
huangchenmin
Posts: 157
Joined: Mon Jun 07, 2010 2:24 am

Re: Where did I go wrong with calldll32 ?

Post by huangchenmin »

dhaine_adp wrote:Hi,

To get a clue please check what h_contromisc.prg is doing on line 7930, is it doing str() on it or trim, etc. Cx05 ...........exception-code-c0000005-access_violation.html
Regards,
Danny
I tried over and over with various combinations of syntax and parameters. one of those is successful and good to apply to other functions in the same DLL file.
I pass the parameter refers to length of buffer with specified space by manual instead of numberic.
For example, the syntax of callinf hisReadPrescriptMain() on maunal like following:
hisReadPrescriptMain(char *pOutpatientPrescription, int *iBufferLenOutpatient, int iStartPos, int iEndPos,int *iRecCount).

The code block use to call function hisReadPrescriptMain() like following:
Local m_par02:=3660,m_par01:=space(m_par02),;
m_par03:=1,m_par04:=60,m_par05:=60
m_ermsg:=calldll32( "hisReadPrescriptMain" , "cshis.dll" ,@m_par01,@m_par02,1,60,@m_par05)

current way like following:
m_ermsg:=calldll32( "hisReadPrescriptMain" , "cshis.dll" ,@m_par01,space(m_par02),1,60,space(m_par05))

I am so happy anf confuse with that .
Best Regards
chen min
User avatar
dhaine_adp
Posts: 457
Joined: Wed Aug 06, 2008 12:22 pm
Location: Manila, Philippines

Re: Where did I go wrong with calldll32 ?

Post by dhaine_adp »

For example, the syntax of callinf hisReadPrescriptMain() on maunal like following:
hisReadPrescriptMain(char *pOutpatientPrescription, int *iBufferLenOutpatient, int iStartPos, int iEndPos,int *iRecCount).

The code block use to call function hisReadPrescriptMain() like following:
Local m_par02:=3660,m_par01:=space(m_par02),;
m_par03:=1,m_par04:=60,m_par05:=60
m_ermsg:=calldll32( "hisReadPrescriptMain" , "cshis.dll" ,@m_par01,@m_par02,1,60,@m_par05)

current way like following:
m_ermsg:=calldll32( "hisReadPrescriptMain" , "cshis.dll" ,@m_par01,space(m_par02),1,60,space(m_par05))
Hi chen min,

I think the cshis.dll is receiving a wrong type of parameter. From the manual, the parameters are:
char
int
int
int
int

The way you pass the variables are:
char
char
int
int
char

Perhaps that is the source of the problem? The function is expecting to received a numeric value but it receives a character instead.

Regards,

Dann
Regards,

Danny
Manila, Philippines
huangchenmin
Posts: 157
Joined: Mon Jun 07, 2010 2:24 am

Re: Where did I go wrong with calldll32 ?

Post by huangchenmin »

dhaine_adp wrote:
''''''''''

The way you pass the variables are:
char
char
int
int
char

Perhaps that is the source of the problem? The function is expecting to received a numeric value but it receives a character instead.

Regards,
Dann
now the way I use is 『char char int int char』and it is done.
that is the reason I confuse about manual.
I already mail to developer of dll.
May have a answer lately.
Best Regards
chen min
Post Reply