Solved

How can I get detailed printer info?

Posted on 1999-01-21
5
269 Views
Last Modified: 2010-04-06
Hi,

I need to obtain the detailed information about a printer:

DriverName
PortName
DeviceName

These things don't seem to be available in the TPrinter object.

Thank you!
MP

0
Comment
Question by:mikepj
  • 2
  • 2
5 Comments
 
LVL 2

Expert Comment

by:lortega
ID: 1362720
to get the printers names do this:

Create a new proyect
add a listbox
add a button
on the click event of the button write
   Listbox1.items.addstrings(printer.printers);
Run it!
0
 
LVL 2

Expert Comment

by:lortega
ID: 1362721
see DeviceCapabilities on your help file
0
 
LVL 8

Accepted Solution

by:
ZifNab earned 100 total points
ID: 1362722
Hi mikepj,

these

DriverName
PortName
DeviceName

can be found by printers.GetPrinter() !

Or you can use the GetPrinter() windows API. ALthough the Printers function getprinter is just an encapsulation of this windows api function...

example :

var
Device : array[0..255] of char;
Driver : array[0..255] of char;
Port   : array[0..255] of char;
hDMode : THandle;
PDMode : PDEVMODE;
begin
  Printer.PrinterIndex := Printer.PrinterIndex;
  Printer.GetPrinter(Device, Driver, Port, hDMode);

---> you got the info you needed : Device, Driver, Port
 
end;

Regards, Zif.


0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1362723
and windows api example :

different levels of info (see api help!)

printers.getprinter uses a different level if on win NT (level 4)or Win95/98 (level 5)

Var
   pInfo: PPrinterInfo2;
   bytesNeeded: DWORD;
   hPrinter: THandle;
           
Begin
  GetPrinter( hPrinter, 2, Nil, 0, @bytesNeeded );
  pInfo := AllocMem( bytesNeeded );
  try
   GetPrinter( hPrinter, 2, pInfo, bytesNeeded, @bytesNeeded );
   With pInfo^ Do Begin

   End;
  finally
   FreeMem( pInfo );
  end;
end;

0
 
LVL 2

Author Comment

by:mikepj
ID: 1362724
Dear ZifNab,

Thank you for your answer; it works!  I had looked a lot at GetPrinter but decided that it didn't have what I needed after I saw that the first three parameters didn't have "var" before them.  Because they're PChar types they don't need to have "var" in front?

Thank you for your help!
MP

0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This video discusses moving either the default database or any database to a new volume.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now