Quantcast
Channel: WinDev Forum
Viewing all articles
Browse latest Browse all 1914

GPF when calling DLL with Structure (1 reply)

$
0
0
I am trying to call a 3rd party DLL from WinDev22, but whenever the function returns data I get either a GPF error or "WDTst.exe has stopped working".

I believe the issue related to the structure that I pass in and is loaded with the return data, it's described in the DLL documentation as ;

typedef struct {
unsigned char aucEPoSNumber[2+1];
unsigned char ucResponseCode;
unsigned char aucAmount[8+1];
unsigned char ucReturnREP;
unsigned char ucPaymentMode;
unsigned char aucResponseData; //optional
unsigned char aucCurrency[3+1];
unsigned char aucPrivateData[10+1];
unsigned char aucOption[(26*99)+1]; //optional (RFU)
unsigned char aucNonConcertData[50000]; //optional
}CDC__S_DATA_RECEIVE;

I've read through the WinDev documentation on DLL calls (API(), CallDLL32() and API Description) and I can see that there can be issues with C strings. So I have tried the methods described in CallDLL32, with defining strings and assigning them so my code looks like this;

s_aucEPoSNumber is string on 2		// unsigned char aucEPoSNumber[2+1]
s_ucResponseCode is string on 1		// unsigned char ucResponseCode
s_aucAmount is string on 8			// unsigned char aucAmount[8+1]	
s_ucReturnREP is string on 1		// unsigned char ucReturnREP	
s_ucPaymentMode is string on 1		// unsigned char ucPaymentMode
s_aucResponseData is string on 1	// unsigned char aucResponseData
s_aucCurrency is string on 3		// unsigned char aucCurrency[3+1]
s_aucPrivateData is string on 10	// unsigned char aucPrivateData[10+1]
s_aucOption is string on (26*99)	// unsigned char aucOption[(26*99)+1]
s_aucNonConcertData is string on 50000	//unsigned char aucNonConcertData[50000]  

strDataToReceive is Structure
  aucEPoSNumber is int
  ucResponseCode is int
  aucAmount is int
  ucReturnREP is int
  ucPaymentMode is int
  aucResponseData is int
  aucCurrency is int
  aucPrivateData is int
  aucOption is int
  aucNonConcertData is int
END

dataReturn is StrDataToReceive

WITH dataReturn
	:aucEPoSNumber=&s_aucEPoSNumber
	:ucResponseCode=&s_ucResponseCode
	:aucAmount=&s_aucAmount
	:ucReturnREP=&s_ucReturnREP
	:ucPaymentMode=&s_ucPaymentMode
	:aucResponseData=&s_aucResponseData
	:aucCurrency=&s_aucCurrency
	:aucPrivateData=&s_aucPrivateData
	:aucOption=&s_aucOption
	:aucNonConcertData=&s_aucNonConcertData
END

iReturn is int = -99
iTimeOut is int = 1*6000
cString is string =  DataToSend()
ConcertTransaction(cString,&dataReturn,iTimeOut)

I've also tried

iReturn=CallDLL32("ComConcert","ConcertTransaction",cString,&dataReturn,iTimeOut)

I've also tried the string length being with the +1, which indicates null terminated values, so for example the aucEPoSNumber as 3 instead of 2. I've also tried all the strings as simple strings and different CallingCOnvention settings.

I've run out of thing to try or read in WinDev help.

Anyone any suggestion or idea on how I could get this to work?

Viewing all articles
Browse latest Browse all 1914

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>