Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!
Access violation |
Post Reply |
Author | |
Kaus Media
Beginner Joined: 31 Jul 06 Location: France Status: Offline Points: 11 |
Post Options
Thanks(0)
Posted: 10 Feb 11 at 12:27PM |
Hello there,
I have an old project which was compiling fine under D2K9 w/ QuickPDF 6. Lately, I have upgraded to D2K10 w/ QuickPDF 7.24ß2 (Tested also 7.14) and I always receive an access violation message which I did not have before with older versions from the RTL library. This message is returned when executing TQuickPDF.Create instruction?! The software has a main program which dynamically load DLLs for various reports, and each of these DLLs are compiled using QuickPDF package in project options. Do you know what causes the trouble? Thanks, Olivier
|
|
KMD
|
|
Kaus Media
Beginner Joined: 31 Jul 06 Location: France Status: Offline Points: 11 |
Post Options
Thanks(0)
|
I have tried from scratch to create an example of the problem... But I cannot reproduce the problem... ?!
|
|
KMD
|
|
Kaus Media
Beginner Joined: 31 Jul 06 Location: France Status: Offline Points: 11 |
Post Options
Thanks(0)
|
Ok. After a long debugging, I have found what's the trouble... And an easy way to reproduce it:
procedure TForm1.Button1Click(Sender: TObject); Var hUserToken: Cardinal; PDF: TQuickPDF; begin If LogonUser ('Administrator','DOMAIN','xxxxxx', LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, hUserToken) then begin If ImpersonateLoggedOnUser(hUserToken) then begin PDF := TQuickPDF.Create; PDF.Free; end; end; end; This was working fine with older versions of QuickPDF I was using but with version 7, I cannot impersonate domain admin and perform a TQuickPDF.Create without an "Access violation" message. Any suggestion?
|
|
KMD
|
|
Dimitry
Team Player Joined: 18 Feb 10 Status: Offline Points: 37 |
Post Options
Thanks(0)
|
Hi Kaus,
Did you try impersonation before loading DLL that contains Quick PDF?
Can you please also check does this problem exist if to use Quick PDF Library DLL/ActiveX editions in your DLL?
|
|
Regards,
Dmitry |
|
Kaus Media
Beginner Joined: 31 Jul 06 Location: France Status: Offline Points: 11 |
Post Options
Thanks(0)
|
Hi Dimitri,
Actually it has nothing to do with DLL loading... Sorry I misled you with my first message... But like I said, after chasing the problem for a few of hours, I was able to reproduce the problem, without any use of DLL nor anything: Just create from scratch a new VCL EXE project (with a main form)... Drop a standard button on its main from... Paste the code given and link it to the onclick event for the button... Compile, run, and push the button... Access Violation at address 004043A1 in module 'Project1'. Read of address 00000008. Thanks for any help provided ;p |
|
KMD
|
|
Kaus Media
Beginner Joined: 31 Jul 06 Location: France Status: Offline Points: 11 |
Post Options
Thanks(0)
|
Ps: Of course, I use valid domain credentials, you have to adapt the code to your own network...
|
|
KMD
|
|
Kaus Media
Beginner Joined: 31 Jul 06 Location: France Status: Offline Points: 11 |
Post Options
Thanks(0)
|
Well... Your suggestion does not work either...I have tried to create the exact same project as described above but using ActiveX instead of VCL component. Project is working perfectly fine without impersonating. But as soon as I add the impersonating instructions, nothing work anymore...
procedure TForm1.Button1Click(Sender: TObject); Var hUserToken: Cardinal; begin If LogonUser ('Administrator','DOMAIN','xxxxx', LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, hUserToken) then begin If ImpersonateLoggedOnUser(hUserToken) then begin PDFLibrary1.UnlockKey(strQuickPDFCode7); PDFLibrary1.DrawText(100, 500, 'Hello from Delphi'); PDFLibrary1.SaveToFile('HelloFromDelphi.pdf'); end; end; end; Error given is now: Project Project1.exe raised exception class EOleSysError with message 'OLE error 80070542, ClassID: {5530475D-F0A2-41BF-AA94-72FA0779289D}
|
|
KMD
|
|
Ingo
Moderator Group Joined: 29 Oct 05 Status: Offline Points: 3524 |
Post Options
Thanks(0)
|
Hi KMD!
If you're using QuickPDF version 7.24 and if you're using Delphi your code should look similar to the following... uses SysUtils, QuickPDF0724, // . . . var QP : TQuickPDF0724; // . . . try QP := TQuickPDF0724.Create; // . . . An EOleSysError raises if a class couldn't be registered/ objectcreation failes. Cheers, Ingo |
|
Kaus Media
Beginner Joined: 31 Jul 06 Location: France Status: Offline Points: 11 |
Post Options
Thanks(0)
|
Hey Ingo,
That's exactly what I mean... TQuickPDF cannot be registered/created with impersonation... Both with VCL component (My first code above) and with ActiveX (The second code above) returns a QuickPDF Create function failure (With either an access violation (VCL) or an EOleSysError (ActiveX)), but ONLY when I impersonate my admin account... See message posted: 14 Feb 11 at 3:54PM. This problem comes with any QuickPDF v7, and was not occuring with older v6... I have strictly, absolutely, no problem to create a QuickPDF object if I don't impersonate: it occurs ONLY with impersonation, and it has nothing to do with DLL loading as I first thought. Please help !!! ;) (I believe I might have to wait for QuickPDF next version...) |
|
KMD
|
|
Kaus Media
Beginner Joined: 31 Jul 06 Location: France Status: Offline Points: 11 |
Post Options
Thanks(0)
|
Still not working with latest 7.24ß4...
|
|
KMD
|
|
Ingo
Moderator Group Joined: 29 Oct 05 Status: Offline Points: 3524 |
Post Options
Thanks(0)
|
So why not asking again on the official support pages?
|
|
Rowan
Moderator Group Joined: 10 Jan 09 Status: Offline Points: 398 |
Post Options
Thanks(0)
|
Some potentially relevant information to this topic can be found here:
Delphi Win32 Service “Printer Selected is not valid” error on 2008 64bit standard server. If you're using Windows Vista or Windows 7 you're going to run into issues with security changes they've made recently, UAC being one of them. The above article mentions printing, but it is going to touch on other areas as well. This wasn't a problem in XP. What operating system are you running on?
|
|
bartvandessel
Beginner Joined: 09 May 11 Status: Offline Points: 1 |
Post Options
Thanks(0)
|
Hi,
I'm dealing with the same problem. Delphi XE & QuickPdf 7.24. Windows 7 64bit
qp := TQuickPDF0724.Create;
Event Log Delphi: Degub Output, CryptoAcquireContext: Failed to read registry signature value at cryptapi.c line 873
Have you already found a solution?
thx Edited by bartvandessel - 09 May 11 at 1:26PM |
|
Ingo
Moderator Group Joined: 29 Oct 05 Status: Offline Points: 3524 |
Post Options
Thanks(0)
|
Hi Bart!
Please have a look at Rowan's post from 31 Mar 11 at 11:35PM. Cheers and welcome here, Ingo |
|
mmolenkp
Beginner Joined: 26 Feb 13 Status: Offline Points: 6 |
Post Options
Thanks(0)
|
My line of code in Delphi 7 was very simple:
rc:=QP.PrintDocument(rc:=QP.PrintDocument, 1, 6, QP.PrintOptions(1, 0, 'Formular'));, 1, 6, QP.PrintOptions(1, 0, 'Formular'));
I get the same kind of error:Invalid printer name.
Much google work done an came on http://www.codenewsfast.com/cnf/article//permalink.art-ng1612q9464
It seems that the delphi 2007 printer unit:Printer.pas is not designed for Vista and up. The referenced entry give the option to change the source of Printer.pas. On vista it solved my problem. |
|
Ingo
Moderator Group Joined: 29 Oct 05 Status: Offline Points: 3524 |
Post Options
Thanks(0)
|
Hi!
First you should try GetPrinterNames to be sure you have the absolutely correct technical printer names in your system. Please keep in mind that the variable for the printer name should be a wide string. I'm still using Delphi 2007 and specially the printer functionalities works and is easy to manage. Cheers and welcome here, Ingo |
|
mmolenkp
Beginner Joined: 26 Feb 13 Status: Offline Points: 6 |
Post Options
Thanks(0)
|
|
|
Ingo
Moderator Group Joined: 29 Oct 05 Status: Offline Points: 3524 |
Post Options
Thanks(0)
|
Hi!
This isn't "your simple line". This was it: rc:=QP.PrintDocument(rc:=QP.PrintDocument, 1, 6, QP.PrintOptions(1, 0, 'Formular'));, 1, 6, QP.PrintOptions(1, 0, 'Formular')); And btw your second line won't work 'cause the function name is wrong (the missing e) ;-) And again the printer unit in Delphi 2007 works in the described case. I've worked with Delphi 2007 under xp/32 bit, vista 64 bit, win7/32 bit and win7/64 bit. Cheers, Ingo Edited by Ingo - 13 Mar 13 at 10:20PM |
|
mmolenkp
Beginner Joined: 26 Feb 13 Status: Offline Points: 6 |
Post Options
Thanks(0)
|
My program was very simpel:
After the modifications made by the mentioned link:
It works only on de default printer, other printers get the message printer not ready
I get the printernames by :QP.GetPrinterNames;
Complete code (77 lines) below
var
Form1: TForm1; QP: TQuickPDF0811; QPKEY, prts : STring; UnlockResult, filea, rc : Integer; npn : string; c : pchar; implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject); begin Edit3.Text:='Pending'; application.ProcessMessages; UnlockResult := QP.UnlockKey(qpkey); if UnlockResult = 1 then begin If FileExists(edit1.text) = true then begin QP.LOADFROMfILE(edit1.text, ''); filea := QP.SelectedDocument(); rc:=QP.PrintDocument(edit2.text, 1, 6, QP.PrintOptions(1, 1, 'Formular')); end; end; { End of Unlock } edit3.Text:=intTostr(rc); end; procedure TForm1.ListBox1DblClick(Sender: TObject);
begin edit2.Text:=listbox1.Items[listbox1.itemindex]; listbox1.selected[listbox1.Itemindex]:=true; end; procedure TForm1.ListBox1Click(Sender: TObject);
begin edit2.Text:=listbox1.Items[listbox1.itemindex]; listbox1.selected[listbox1.Itemindex]:=true; end; procedure TForm1.FormCreate(Sender: TObject);
begin QPkey:= 'Mykey'; QP := TQuickPDF0811.Create; edit2.text:= QP.GetDefaultPrinterName(); prts:=QP.GetPrinterNames; listbox1.Clear; listbox1.Items.DelimitedText:=prts; listbox1.Itemindex:=listbox1.items.indexof(edit2.text); listbox1.selected[listbox1.Itemindex]:=true; end; end. |
|
Ingo
Moderator Group Joined: 29 Oct 05 Status: Offline Points: 3524 |
Post Options
Thanks(0)
|
Hi!
I see edit2.text... Newer versions of QuickPDF need a wide-string! If your technical printer name contains spaces perhpas this could be a second problem. This is my code and it works very well. PriName is declared as WideString. if ( prname = 'default') Then PriName := QP.GetDefaultPrinterName Else PriName := prname; propt := QP.PrintOptions(pscal, 0, filename); pc := QP.PageCount; for i := 1 to copies do begin QP.PrintDocument(PriName, 1, pc, propt); end; |
|
mmolenkp
Beginner Joined: 26 Feb 13 Status: Offline Points: 6 |
Post Options
Thanks(0)
|
Ik Have declared the printer name as follows : var ws_prtname : WideString;
Ik give no difference.
When i use the default printer.pas I get failure : Invalid printer name.
When I use the modified printer.pas I get failure : Device not ready
I think there must be something wrong in the printer.pas or other units of Delphi 7.
|
|
mmolenkp
Beginner Joined: 26 Feb 13 Status: Offline Points: 6 |
Post Options
Thanks(0)
|
There is no difference of making changes in string or widestrings definitions.
My system is a Vista 64 bit Sp2 with QPDF 0812.
But I fund a solution for my problem !!!
I Insert the folowing line of code : cPrinter:=qp.NewCustomPrinter(edit2.text);
I can't explain why this is a solution, but it works.
Another strange effect what I have seen is that without that line of code the error "Invalid printername" comes up and after that, QPDF returns on a not expected point in my program.
3 lines of code after the END statement which should be the return point.
So I think there is a failure in the QPDF.PrintDocument error recovery, becuase i am 100% sure that the printer name i use is the right one. I retrieve them by QPDF.Getprinternames;
To solve this last failure I put a Try Except clause around the QPDF.PrintDocument statement..
|
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |
Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. About — Contact — Blog — Support — Online Store