Solved

How can I get detailed printer info?

Posted on 1999-01-21
5
285 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 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 Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

734 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