Solved

How can I get detailed printer info?

Posted on 1999-01-21
5
270 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Newbie Thread Programming 1 139
Delphi XE10, MySQL Query 4 127
How to call a form that is in a DLL  from an application? 13 65
Delphi inherited method 6 63
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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

867 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

18 Experts available now in Live!

Get 1:1 Help Now