Avatar of Thomas Stockbruegger
Thomas Stockbruegger
Flag 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
Visual C++.NETC++Programming

Avatar of undefined
Last Comment
Thomas Stockbruegger

8/22/2022 - Mon
SOLUTION
Zoppo

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
ASKER CERTIFIED SOLUTION
sarabande

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Thomas Stockbruegger

ASKER
thank you, that was very fast
best regards,
Thomas
Thomas Stockbruegger

ASKER
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))
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23