Archive: Calling external Functions with System::Call


Calling external Functions with System::Call
Hi, I have a problem using a function in a third Party-dll. In fact I have two problems ;-)

1. I do not have a documentation about the external lib.
2. I dont understand the syntax of the System::Call call.

but I have found an example Install Shild Script where the functions I have to call, are used. So maybe anyone of you can help me with that. Ok, lets start with the three functions I have to call:

in install script they are defined the following:


prototype gptsbinstlms11.GlmsPMKVerify_32( POINTER, BOOL, POINTER, POINTER, POINTER);
prototype gptsbinstlms11.GlmsFileSetupKeys(POINTER, POINTER, POINTER);
prototype gptsbinstlms11.GlmsPrdInstallSetup(POINTER, int, POINTER, POINTER);


And here is a function which calls the functions in the dll (also from install shild)

function BOOL CreateGLMSFile(szInstallDir,szValue)
string svName,svInstallDir,svValue;
POINTER pvInstallDir,pvPMCKey;
number ipRefCount;
long lvPrdInstallSetup;
number nvRetSetupKey;
begin

if UseDLL( GLMSSBInst10 ) != 0 then
MessageBox("Failed to load " + GLMSSBInst10, SEVERE);
return FALSE;
endif;
svName = LICENSEAPPNAME;
//nvSize = -1;
svValue=szValue;
svInstallDir = szInstallDir;
pvInstallDir = &svInstallDir;
nvRetSetupKey=GlmsFileSetupKeys(&svName,&svValue,pvInstallDir);

if(nvRetSetupKey=-1) then
return FALSE;
endif;

ipRefCount = 1;
pvPMCKey = &svValue;
pvInstallDir = &svInstallDir;

lvPrdInstallSetup = gptsbinstlms11.GlmsPrdInstallSetup(pvPMCKey,
&svName, ipRefCount, pvInstallDir);
if(lvPrdInstallSetup!=94555) then
return FALSE;
endif;


if UnUseDLL( GLMSSBInst10 ) != 0 then
MessageBox("Failed to unload " + GLMSSBInst10, SEVERE);
return FALSE;
endif;

return TRUE;


Thanks for any advise or help you can give.

Marco

Ok, here's my first try:


Function GLMS_Register
Var /GLOBAL bRet
SetOutPath $TEMP\glms
# Save variables in Stack
push $0
push $1
push $2
push $3

strcpy $bRet "true"
strcpy $0 ${LICENSEAPPNAME}
strcpy $1 $INSTDIR
strcpy $2 "XXXXXXXX-XXXXXXXX-XXXXXXXX-XXXXXXXX"

File /oname=$TEMP\glms\glms.dll C:\Gupta\SQLBase_EDP\InstallComponents\glms\gptsbinstlms11.dll
System::Call 'glms::GlmsFileSetupKeys(t, t, t) i(r0, r1, r2) .r3'

MessageBox MB_OK "Wert, der Zurück kam: $3"
intCmp $3 -1 error 0 0

System::Call 'glms::GlmsPrdInstallSetup(t, t, i, t) l(r1, r0, 1, r2) .r3'
IntCmp $3 94555 done error error

error:
DetailPrint "Fehler aufgetreten beim Registrieren des Servers. Bitte PMC"
StrCpy $bRet "false"
done:
System::Free 0

# restore variables
pop $3
pop $2
pop $1
pop $0
push $bRet
Return
FunctionEnd


but this doesn't work: $3 is empty after the first System::Call
Edit: I found an error.. still trying
Edit: mhh the return value from the first function call is -1

best regards Marco

Ok, I got it, for my purposes I only need the function GlmsFileSetupKeys which in c is defined as

long GlmsFileSetupKeys(char*, char*, char*)

so my call is:

System::Call 'glms::GlmsFileSetupKeys(t r0, t r1, t r2) l .r3'

bye Marco