I am successfully calling a function in a DLL from Inno Setup, however upon returning I get a Runtime Error...Exception: Access violation at address XXXXXXX. Write of address XXXXXX.
The function is declared as:
function CompleteInstall(szIntallPath: String) : Integer;
external 'CompleteInstall@files:InstallHelper.dll stdcall setuponly';
And called:
procedure CurStepChanged(CurStep: TSetupStep);
begin
if CurStep = ssPostInstall then begin
CompleteInstall('Parm1'); // ExpandConstant('{app}')
end;
end;
There is no problem if I change the function to not take a parameter. It still occurs if I change it to take a single integer parameter or declare it as a function and change the function to be a void function with an integer parameter.
The called function does nothing but return:
__declspec(dllexport) int CompleteInstall(char* szInstallPath)
{
//AfxMessageBox ("Got here" /*szInstallPath*/, MB_OK);
return 1;
}
You have a mismatch of the calling conventions. Either make the DLL function use stdcall
as well:
__declspec(dllexport) __stdcall int CompleteInstall(char* szInstallPath)
{
//AfxMessageBox ("Got here" /*szInstallPath*/, MB_OK);
return 1;
}
or change the function declaration to use cdecl
instead of stdcall
:
function CompleteInstall(szIntallPath: String) : Integer;
external 'CompleteInstall@files:InstallHelper.dll cdecl setuponly';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With