Hello,
I would like to change the name of the printer into a string.
This is my code that works:
if (GetPrinterDevice(_T("\\\\DSERVER\\Brother HL-7050 series"), &hDevNames, &hDevMode))
I have tried this one, but it will not work:
void CZahlen_SortierenDlg::OnBn
ClickedBut
ton1()
{
HANDLE hDevMode;
HANDLE hDevNames;
CString D="\\\\\\\\DSERVER\\\\Brother HL-7050 series";
LPCSTR drucker=(LPCSTR)(LPCSTR)D;
// if (GetPrinterDevice(_T("\\\\
DSERVER\\B
rother HL-7050 series"), &hDevNames, &hDevMode))
if (GetPrinterDevice(
drucker), &hDevNames, &hDevMode)
{
AfxGetApp()->SelectPrinter
(hDevNames
, hDevMode);
CPrintDialog dlgPrint(FALSE,PD_PAGENUMS
|PD_USEDEV
MODECOPIES
ANDCOLLATE
, this);
//------------------------
--- Papier Auswahl DEVMODE --------------------------
--------
if(AfxGetApp()->GetPrinter
DeviceDefa
ults(&dlgP
rint.m_pd)
)
{
LPDEVMODE dev=dlgPrint.GetDevMode();
GlobalUnlock(dev);
dev->dmOrientation=DMORIEN
T_PORTRAIT
; //Hochformat
dev->dmPaperSize=DMPAPER_A
4;
dev->dmCopies=1;
dev->dmDefaultSource=DMBIN
_AUTO;
I will get this error:
![error]()
Thank you for your help,
Best regards,
Thomas
thank you for your answer.
I changed my code to this:
void CZahlen_SortierenDlg::OnBn
{
CString D="\\\\\\\\DSERVER\\\\Brot
LPCSTR drucker=(LPCSTR)D;
HANDLE hDevMode;
HANDLE hDevNames;
if (GetPrinterDevice((LPSTR)d
{
AfxGetApp()->SelectPrinter
I will get no error.
But in GetPrinterDevice the printer will not be recognized.
bool CZahlen_SortierenDlg::GetP
{
// if NULL is passed, then assume we are setting app object's
// devmode and devnames
if (phDevMode == NULL || phDevNames == NULL)
{
MessageBox("EPSON LQ-680Pro Port 2 Wiegekarte-1error");
return FALSE;
}
// Open printer
HANDLE hPrinter;
if (OpenPrinter(pszPrinterNam
{
MessageBox("Can not find printer"); will get this message
return FALSE;
}
When I look at the string with a break point, it looks the same as in writing "\\\\DSERVER\\Brother HL-7050 series"