Link to home
Create AccountLog in
Avatar of Thomas Stockbruegger
Thomas StockbrueggerFlag for Germany

asked on

Need some help with GetPrinterDevice

Hello,
I would like to change the call to  GetPrinterDevice like this  
if (GetPrinterDevice(_T("7-PDF Printer"), &hDevNames, &hDevMode))

to a string, but this will not work
if (GetPrinterDevice (PDF_DRUCKER), &hDevNames, &hDevMode))

      
      

       CString str_PDF="7-PDF Printer";

        LPTSTR string = new TCHAR[str_PDF.GetLength()+1];
       _tcscpy(string,str_PDF);
       strcpy(PDF_DRUCKER,string);
 
       if (GetPrinterDevice (PDF_DRUCKER), &hDevNames, &hDevMode))

please let me know
500 points with a solution.
Thank you.
Best regards,
Thomas
SOLUTION
Avatar of Zoppo
Zoppo
Flag of Germany image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
ASKER CERTIFIED SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of Thomas Stockbruegger

ASKER

thank you, that was very fast
best regards,
Thomas
This will work, and you have to use GetBuffer()

CString str_PDF=_T( "7-PDF Printer" );
if (GetPrinterDevice (str_PDF.GetBuffer(str_PDF.GetLength()+1), &hDevNames, &hDevMode))