Recent

Author Topic: pdfiumLib port - and Windows.ShellExecute unexpected Pchar PwideChar error  (Read 2819 times)

PaulANormanNZ

  • Full Member
  • ***
  • Posts: 117
Hi,

I just went to incorporate the very useful pdfiumLib port into an existing project CPUX64.

(It has a relatively low memory footprint compared to other things I have tried)

https://forum.lazarus.freepascal.org/index.php?action=dlattach;topic=40938.0;attach=26219

... First post in...

https://forum.lazarus.freepascal.org/index.php/topic,40938.msg303532.html#msg303532

The example pdfium app that comes with the library for Lazarus has been working well, and I have been able to experiment with it, modify, and enlarge it successfully.

However when incorporating the control into an existing CPUX64 Windows project, I suddenly get errors where I call windows.ShellExecute ...

main.pas(53,58) Error: Incompatible type for arg no. 4: Got "PWideChar", expected "PChar"

(Shell Execute works well when absolutely all references to pdfium are commented out).

I believe that it may be a {Mode} string issue of some sort - but I can not track it down.

I've made a minimum project (attached) to try and show the problem.

You'll need to get the Pdfium.dll from Taazz's link, as its too big to include here.

https://github.com/pvginkel/PdfiumViewer/tree/releases/2.12.0.0/Libraries/Pdfium/x64

Put it in the project directory.

The project will only compile if you comment out lines 53 and 54 removing the ShellExecute

Any help appreciated please as I would really like to use this pdfium control.

Paul

P.S.
I'm using TProcess meanwhile, but it does not cope with network paths ( e.g. \\copmuter\sharedfolder\etc ) and would like to solve it any way just incase I encounter a shellexecute PChar type problem else wise in my main project.
« Last Edit: December 03, 2018, 10:17:46 am by PaulANormanNZ »

ASerge

  • Hero Member
  • *****
  • Posts: 2240
Re: pdfiumLib port - and Windows.ShellExecute unexpected Pchar PwideChar error
« Reply #1 on: December 03, 2018, 06:42:45 pm »
The project will only compile if you comment out lines 53 and 54 removing the ShellExecute
I will not say anything for pdfiumLib, but try it this way:
Code: Pascal  [Select][+][-]
  1. procedure TForm1.ExplorerClick(Sender: TObject);
  2. var
  3.   FileDetail: UnicodeString;
  4. begin
  5.   FileDetail := '/select,' + UTF8Decode(FileListBox1.FileName);
  6.   ShellExecuteW(0, nil, 'explorer.exe', PWideChar(FileDetail), nil, SW_SHOWNORMAL);
  7. end;

PaulANormanNZ

  • Full Member
  • ***
  • Posts: 117
Re: pdfiumLib port - and Windows.ShellExecute unexpected Pchar PwideChar error
« Reply #2 on: December 04, 2018, 12:30:11 am »
Thanks ASerge,

Your solution is very helpful - as I also use the 'edit' option in ShellExecute(W) in my main project and it is good to be able to easily continue to do so.
I have never had cause to look at ShellExecuteW before.

I think perhaps with pdfiumLib there is a something parallel to a conflict of {Mode(s)} when the units are used in a general Lazarus project?
This may still need a more generic solution, as occasionally in the future - with other things  PChar(s) may be unavoidable? Or will the kind of approach you've taken be good longterm - as it may cone up with other ported libraries as well anyway?

I would recommend the use of Taazz's port of pdfiumlib to anyone.
It is stable, extremely quick, and as I said low memory footprint compared to other options I have tried, and it is available 32 and 64bit. (Could only find 32 for MuPdf so far).
Chromium is perhaps overkill if you only need it for pdfs - and pdfium is the pdf handling subset of that anyway.

Just a small useful thing, with pdfium the pageup and pagedown keys work out of the box if the control has focus, and Crtl-Home and Crtl-End take you to the first and last pages.

Thanks again!
Paul
« Last Edit: December 04, 2018, 12:47:01 am by PaulANormanNZ »

 

TinyPortal © 2005-2018