BOOL CDispDataView::GetDefaultPrinter(LPTSTR szPrinterName, int nPrintNameBufferLen)
{ *szPrinterName = 0; CPrintDialog pd(FALSE); if (pd.GetDefaults()) { if (pd.m_pd.hDC) DeleteDC(pd.m_pd.hDC); if (pd.m_pd.hDevNames) { LPDEVNAMES pdn = (LPDEVNAMES)GlobalLock(pd.m_pd.hDevNames); nPrintNameBufferLen--; *(szPrinterName + nPrintNameBufferLen) = 0; _tcsncpy(szPrinterName, (LPTSTR)pdn + pdn-> wDeviceOffset, nPrintNameBufferLen); //打印机名称 GlobalUnlock(pd.m_pd.hDevNames); GlobalFree(pd.m_pd.hDevNames); } } return (*szPrinterName); }