Print Page | Close Window

Linux shared object with Delphi - DPLUnlockKey

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: I need help - I can help
Forum Description: Problems and solutions while programming with the Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=3701
Printed Date: 29 Apr 24 at 2:18PM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Linux shared object with Delphi - DPLUnlockKey
Posted By: Coogara
Subject: Linux shared object with Delphi - DPLUnlockKey
Date Posted: 24 Apr 19 at 2:46AM
I'm having trouble getting going with calling a shared object from Delphi on Linux for the DPLUnlockKey method. Granted it could be the license key, but it was obtained today with our purchase of the Linux license. Maybe someone could compare with what they're doing on Linux.

I'm loading my library dynamically with LoadLibrary, after which I GetProcAddress. So far (error checking omitted):

type
  TDPLCreateLibrary = function: integer; stdcall;
  TDPLReleaseLibrary = procedure (InstanceID: integer); stdcall;
  TDPLUnlockKey = function (InstanceID: integer; LicenseKey: PWideChar): integer; stdcall;

var
  DPLCreateLibrary: TDPLCreateLibrary;
  DPLReleaseLibrary: TDPLReleaseLibrary;
  DPLUnlockKey: TDPLUnlockKey;
...
  LibHandle := LoadLibrary('libQPLLinux1612-x86_64.so');

  @DPLCreateLibrary := GetProcAddress(LibHandle, 'DPLCreateLibrary');
  @DPLReleaseLibrary := GetProcAddress(LibHandle, 'DPLReleaseLibrary');
  @DPLUnlockKey := GetProcAddress(LibHandle, 'DPLUnlockKey');

  InstanceID := DPLCreateLibrary;
  writeln('InstanceID: ', InstanceID);
  R := DPLUnlockKey(InstanceID, pchar(DEBENU_PDF_KEY));
...
Lirbary loads okay. InstanceID is non-zero. R (returned by DPLUnlockKey) is always 0. I've tried various syntax on the method type declaration with no success. Thoughts? Any ideas?



Replies:
Posted By: Ingo
Date Posted: 24 Apr 19 at 11:06AM
Hi Coogar,

the unlock-function needs a wide char entry for the key-value - perhaps that's the problem?
https://www.debenu.com/docs/pdf_library_reference/UnlockKey.php
If that's not the problem then perhaps your license key isn't valid anymore (30 days)?

I think you didn't find the official publisher pages for the first steps?
Here they are:
https://www.debenu.com/products/development/debenu-pdf-library/getting-started/
and here:
https://www.debenu.com/products/development/debenu-pdf-library/help/samples/

Cheers and welcome here,
Ingo



-------------
Cheers,
Ingo



Posted By: Coogara
Date Posted: 24 Apr 19 at 7:30PM
Thanks for the links. I had, in fact, seen the sample code you mention but had not made any headway with them for the Delphi/Linux combination using WideString.

As I could not get this to work with a wide string, I opted to change the declaration of the method to use AnsiString, and reference the ANSI version of the method:

  TDPLUnlockKey = function (InstanceID: integer; LicenseKey: AnsiString): integer; stdcall;
...
  @DPLUnlockKey := GetProcAddress(LibHandle, 'DPLUnlockKeyA');
...
  r := DPLUnlockKey(InstanceID, AnsiString(DEBENU_PDF_KEY));

The DPLUnlockKey now returns 1 instead of zero. I will make further attempts to get this to work with a wide string.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk