Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

can't print using TPrinter through Network Printer under NT4.0

135 views
Skip to first unread message

Ben Chan

unread,
Dec 15, 1999, 3:00:00 AM12/15/99
to
I can't print using TPrinter through Network Printer under NT4.0.
"EAccessViolation" occurs,

Can any one knows the solution? Thanks.

uses Printer;

var Prt: TPrinter;

procedure TForm1.PrintProc;
begin
with Prt do begin
BeginDoc;
.........
NewPage.....
......
EndDoc;
end;
end;


lsoft

unread,
Dec 15, 1999, 3:00:00 AM12/15/99
to
If you use own TPrinter object, you must first create it, like any other
objects.

In the OnCreate method of the form use: Prt := TPrinter.Create, in the
OnDestroy method of the form use Prt.Free.

When you use the predeclared Printer variable, you must not create and
destroy it.

Ben Chan <ben_...@usa.net> az alábbiakat írta a következő hírüzenetben:
385721DB...@usa.net...

Ben Chan

unread,
Dec 15, 1999, 3:00:00 AM12/15/99
to
I've created it.

I can print things successfully using a standalone printer through LPT
but when I use network printers, AccessViolation occurs whenever executing
"BeginDoc"....

Davie Reed

unread,
Dec 17, 1999, 3:00:00 AM12/17/99
to
Hmmmmm, I am using D4 and use the TPrinter and begindoc etc... and I have 2
PC's networked together. The server is an older 200mhz that is basically a
printer sever. So my main 450Mhz system uses the network printer to print
everything and it works fine.

Do you have a small code snippet that compiles that I can try?

Davie

Adrian Bawn

unread,
Jan 6, 2000, 3:00:00 AM1/6/00
to
I have a similar problem...

I get the same access violation, but if you continue the program execution
you will see that it is complaining about "No Default Printer".

It comes as a result of the delphi (and the delphi IDE) app thinking there
is no default printer if you only have networked printers, or if the
networked printer is the default.

(BTW: I am using D3 and D5, both of which exibit the problem)

There is a default, but it cant see it !

Another delphi programmer told me that the default printer needs to be
stored in UPPER case in the registry for Delphi to be able to understand it,
but this doesnt always work (nor do the entries remain uppercased).

If anyone has a solution to this problem, could then e-mail it to me as well
as posting to the group, as I dont get a chance to check the group that
often.


I dont think any kind of "code snippet" would be of use if you system is
working at the mo due to it being a Delphi functionality issue as opposed to
a programming issue.


Thanks

Adrian Bawn, Intermediate IT Systems Engineer
E-mail: adria...@uk.coltgroup.com


Davie Reed wrote in message <3859D754...@smatters.com>...

Peter Below

unread,
Jan 7, 2000, 3:00:00 AM1/7/00
to
In article <85266e$q6...@bornews.borland.com>, Adrian Bawn wrote:
> I have a similar problem...
> I get the same access violation, but if you continue the program execution
> you will see that it is complaining about "No Default Printer".
> It comes as a result of the delphi (and the delphi IDE) app thinking there
> is no default printer if you only have networked printers, or if the
> networked printer is the default.

Adrian, perhaps the following thread i saved some time ago can help you fix
the problem:

<quote>
"No default printer" problem on NT

My problem : I am using several WinNT workstations that cannot print (only
when using Delphi apps)
----------------------------------------------------------------------------
--------------------------
Tried NT4-SP4&5

I have completely reinstalled the Delphi IDE, etc on another workstation -
same results

( PS older NT workstation-SP3 appears to work OK ?!?!?!? )

Now . . . .

The Delphi PRINTERS unit has a procedure SetToDefaultPrinter

This uses the WINAPI call . . . . .
EnumPrinters(PRINTER_ENUM_DEFAULT, nil, 5, PrinterInfo, ByteCnt, ByteCnt,
StructCnt)

& if it fails, it raises an exception with message "There is no default
printer . . . ." AND THEN NO PRINTING

HOWEVER, the WINAPI Help description for EnumPrinters indicates clearly that
the PRINTER_ENUM_DEFAULT option is ONLY available with Windows95 and NOT
under WinNT.

[Aside: The August 1999 TechNET indicates that the parameters for
EnumPrinters are different for Win95 & WinNT]

Is the Delphi PRINTERS unit in error ??
If so, how do I fix it ?

From: "Brian Cahill" <Brian...@SoftHome.net>
Newsgroups: borland.public.delphi.winapi
Subject: Re: <Default Printer> problem ( BUG ?? )
Date: Thu, 19 Aug 1999 08:23:17 +1000

FOUND (I think !)

Did a little more digging - found that the ENUMPRINTERS device names are in
full uppercase
whereas the DefaultPrinter comes back with the server name part in lower
case !!

In a 'local' copy of the PRINTERS unit, I changed the comparison line to
if Uppercase(TPrinterDevice(Objects[I]).Device) = Uppercase(Device)

AND it works OK !

</quote>
Peter Below (TeamB) 10011...@compuserve.com)
No replies in private e-mail, please, unless explicitly requested!

Sent using Virtual Access 5.00 - download your freeware copy now
http://www.atlantic-coast.com/downloads/vasetup.exe

0 new messages