Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How can I get detailed printer info?

Posted on 1999-01-21
5
Medium Priority
?
304 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 300 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 Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

721 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