Windows memory error with CStructCopyFromFarMem (2005-2010)
Simon Agar

Windows memory error with CStructCopyFromFarMem

Post by Simon Agar » 16 Jan 2009, 15:08

 Posted by:  Simon Agar 


In the below code I pass and receive data (CallCSPCSV) through a dll written in Delphi. If the connection to the server is terminated and I run this code the TestConnection() fails and the Return FALSE is executed. When the connection to the server is re-established, the TestConnection() succeeds but I get a windows error on the CStructCopyFromFarMem line. I do not execute any other code in-between. Could anybody help please? I tried formally re-establish the connection in my code but that does not work. Attached is the windows error.

I'm using TD3.0.0-PTF4 Build 13612.


!!CB!! 72
If Not TestConnection()
Set p_sErrorMsg = APP_FMISString_CommsError
Return FALSE
Set nPointerToBuffer1 = CStructAllocFarMem(APP_FMISString_ShortStringLength)
Set nPointerToBuffer2 = CStructAllocFarMem(APP_FMISString_ShortStringLength)
Call CStructCopyToFarMem( nPointerToBuffer1, p_sSend1, APP_FMISString_ShortStringLength-1 )
Call CStructCopyToFarMem( nPointerToBuffer2, p_sSend2, APP_FMISString_ShortStringLength-1 )
If Not CallCSPCSV(nPointerToBuffer3, nPointerToBuffer2, nPointerToBuffer1)
Call CStructFreeFarMem(nPointerToBuffer1)
Call CStructFreeFarMem(nPointerToBuffer2)
Call SalStrSetBufferLength(p_sReturn, APP_FMISString_ShortStringLength)
Call CStructCopyFromFarMem(nPointerToBuffer3, p_sReturn, APP_FMISString_ShortStringLength-1)
Set p_sErrorMsg = "Error calling FMIS function: "||SalStrTrimX(p_sSend1)
If p_sReturn != STRING_Null
Set p_sErrorMsg = p_sErrorMsg||"- "||SalStrTrimX(p_sReturn)||"."
Set p_sErrorMsg = p_sErrorMsg||"."
Return FALSE
If nPointerToBuffer3 = 0
Call CStructFreeFarMem(nPointerToBuffer1)
Call CStructFreeFarMem(nPointerToBuffer2)
Set p_sErrorMsg = "Error getting return parameter from FMIS Server."
Return FALSE
Call SalStrSetBufferLength(p_sReturn, APP_FMISString_LongStringLength)
Call CStructCopyFromFarMem( nPointerToBuffer3, p_sReturn, APP_FMISString_LongStringLength-1 )
Call CStructFreeFarMem(nPointerToBuffer1)
Call CStructFreeFarMem(nPointerToBuffer2)

Simon Agar
Application Development Section
Nelson Mandela Bay Municipality
Tel: +27 41 506 1226
Fax: +27 86 669 7486
Cell: +27 82 491 7862

Attachment: Doc1.doc

Dave Rabelink
Founder/Site Admin
Founder/Site Admin
Posts: 2813
Joined: 24 Feb 2017, 09:12
Location: Gouda, The Netherlands

Windows memory error with CStructCopyFromFarMem

Post by Dave Rabelink » 21 Jan 2009, 20:39

Where do you allocate farmem for nPointerToBuffer3 ?

Return to “td.development”

Who is online

Users browsing this forum: [Ccbot] and 0 guests