I have the following functions defined for a 3rd-party DLL, which we don't have control over:
const
DLL = 'Qarapea.dll';
function QARapid_Open(IniFile: shortstring; Section: shortstring): integer; stdcall; external DLL;
procedure QARapid_EndSearch(); stdcall; external DLL;
function QARapid_Count: integer; stdcall; external DLL;
function QARapid_Search(vs: shortstring): integer; stdcall; external DLL;
function QARapid_FormatAddr(ItemNumber: integer; Buffer: PAnsiChar; BufferSize: integer): integer; stdcall; external DLL;
procedure QARapid_Close; stdcall; external DLL;
I call the functions in the following way:
procedure TFormMain.ButtonStaticLookupClick(Sender: TObject);
var
Res: integer;
ACode: shortstring;
IniFile, Section: shortstring;
begin
try
ACode := PrepareCode(EditCode.Text);
IniFile := ExtractFilePath(ParamStr(0)) + 'DllIni.ini';
Section := 'Default';
QARapid_Open(IniFile, Section);
try
Res := QARapid_Search(ACode);
Res := QARapid_Count;
finally
QARapid_Close;
end;
Except on E: Exception do
MessageDlg(E.Message, mtError, [mbOK], 0);
end;
end;
Everything seems to be OK until I call the QARapid_Count
function, when I get the following error:
QAS.exe faulted with message: Privileged instruction at 0x0012eff4. Process stopped. Use step or run to continue.
I'm don't know where to start looking for the fault because the CPU debug window is opened.
How can trace what is going wrong?