Link to home
Start Free TrialLog in
Avatar of mikepj
mikepjFlag for Canada

asked on

How can I get detailed printer info?

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

Avatar of lortega
lortega

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!
see DeviceCapabilities on your help file
ASKER CERTIFIED SOLUTION
Avatar of ZifNab
ZifNab

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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;

Avatar of mikepj

ASKER

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