Export (0) Print
Expand All

CPrintDialog::GetDeviceName 

Retrieves the name of the currently selected printer device.


CString GetDeviceName( ) const;

The name of the currently selected printer.

Call this function after calling DoModal to retrieve the name of the currently selected printer, or after calling GetDefaults to retrieve the current device defaults of the default printer. Use a pointer to the CString object returned by GetDeviceName as the value of lpszDeviceName in a call to CDC::CreateDC.

This code fragment shows the user's default printer name and the port it is connected to, along with the spooler name the printer uses. The code might show a message box that says, "Your default printer is HP LaserJet IIIP on \\server\share using winspool.", for 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);
}

Community Additions

ADD
Show:
© 2014 Microsoft