PDA

View Full Version : Call DLL adventures



MarkRiffey
01-26-2021, 08:55 PM
Friedrich,

I am using a DLL we've called from SB for a long time - and it finally needed some changes.

For reasons I have not been able to determine, the DLL works when called by a small hand code app, but GPFs when SB calls it. Given that the SB doc indicates that mangling is a no-no, I thought maybe that was the problem, but there's no mangling.

Prototype: GetPCC(*CSTRING PCC_CODE),SHORT,NAME('GetPCC') - I have also tried (STRING PCC_CODE) with the same results (GPF).

Whether I call the DLL with a SB runtime variable that is empty, or one that has contents, SB GPFs. The odd thing is that this installer has been around for quite some time, and likewise has the parameter.

If I remove the parameter from the DLL's prototype, SB works fine.

Screenshot of SB setup image and prototype in code: https://p168.p3.n0.cdn.getcloudapp.com/items/rRukwrxD/06facbc0-a88e-40b9-a573-7a835c932a1b.png?v=53e641f63ba71df0b579c29efe754d8 9

It's unclear what I am doing incorrectly, but I'm sure there's something.

Mark

linder
01-27-2021, 10:44 AM
Hi Mark,

Would it be possible to send me the DLL (and the source code of the small hand coded app) so I can check it?

Friedrich

MarkRiffey
01-30-2021, 03:47 PM
Hi Mark,

Would it be possible to send me the DLL (and the source code of the small hand coded app) so I can check it?

Friedrich

Friedrich,

I found another way around it. I think the problem has something to do with my assumptions about how inbound parameters are handled and how I coded for them. The workaround provides better future flexibility so it was actually a good thing that I hit this problem.

I ripped out all the stuff that doesnt matter to make this post easier to deal with, so the essence of the program was as follows:

PROGRAM

MAP
!ORIGINAL ALLEGEDLY WORKING<G> PROTOTYPE GetPCC(PCC_CODE),SHORT,NAME('GetPCC')
GetPCC(STRING PCC_CODE),SHORT,NAME('GetPCC') ! GPFs when SB calls it.
END

PCC_STATUS SHORT

CODE
!----------------------
GetPCC PROCEDURE(STRING PCC_CODE)!,SHORT ! Used by full installation program to get and check the PCC code
!----------------------
PAC_STRING CSTRING(1000)

CODE

IF CLIP(PCC_CODE) > ' '
PAC_STRING = PCC_CODE
ELSE
RETURN(-1)
END

! evaluate pcc_code here

RETURN(PCC_STATUS)



BTW, the exp that used to work but stopped working was:
NAME GetPCC GUI
EXPORTS
GetPCC @1

Mark