Subject more licensing API blues
Author stuartideagen
Hi,
I wonder if anyone can help. I'm trying to use the InterBase
licensing API from within a Delphi application, and thought I had it
working but am getting strange things happening to my application
after calling the functions (variables being reset, AVs etc.). I am
aware that when calling a DLL these are normally caused by the
function declaration being wrong, but I can't see a problem. For
example, the sample app below registers the ID/Key pair ok (if you
put a valid set in there), but then crashes. (actually when it tries
to return from the button click method, indicating a problem with the
stack). If anyone can tell me what I'm doing wrong, or give me the
correct Delphi function definitions I'd be very grateful.
Stuart Hunt

var
Form1: TForm1;
hLicenceDLL: THandle;

//I suspect the problem is with this declaration, but can't see what
ISC_License_Add:
function (const cert_id, cert_key: PChar): Integer; stdcall;

implementation

{$R *.dfm}

procedure TForm1.FormShow(Sender: TObject);
begin
hLicenceDLL:=LoadLibrary('c:\program
files\borland\interbase\bin\iblicense.dll');
if hlicenceDLL=HINSTANCE_ERROR
then raise exception.Create('cannot load dll');
@ISC_License_Add:=GetProcAddress(hLicenceDLL, 'isc_license_add');
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
FreeLibrary(hLicenceDLL);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
ISC_License_Add('<id>', '<key>');
end;