Link to home
Start Free TrialLog in
Avatar of vku
vku

asked on

Default Printer Name from Registry

Hi,

Is there a way to get Default Printer Name , Port Number and the Driver Name and their PATH from the Registry? And is it possible through Microsoft Java?

Please Help.

Thanks a lot,
VK

ASKER CERTIFIED SOLUTION
Avatar of sgupta00
sgupta00

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
Avatar of Chandra V
Chandra V

If you are in Windows 95 or 98 the information is found in

"HKEY_LOCAL_MACHINE\\System\\CurrentControlSet\\Control\\Print\\Printers\\"

Driver - "Printer Driver"
Port   - "Port"

Otherwise you can get the printer name using API

DEVMODE FAR *pDevMode=(DEVMODE FAR *)::GlobalLock(m_hDevMode);

and accessing 'pDevMode->dmDeviceName'
Use the CPrintDialog class:

example:

CPrintDialog dlg(FALSE);

if (!dlg.GetDefaults())
   AfxMessageBox(_T("You have no default printer!"));
else
{
   CString strDescription;

   strDescription.Format(_T("Your default printer is %s on %s using %s."),
      (LPCTSTR) dlg.GetDeviceName(),
      (LPCTSTR) dlg.GetPortName(),
      (LPCTSTR) dlg.GetDriverName());

   AfxMessageBox(strDescription);
}

Tim Musschoot
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Answered by : sgupta00

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Roshan Davis
EE Cleanup Volunteer