printing - CPrintDialog Creation Failing in Service Mode of an Application -


I have an application that automatically prints the report. I'm using CPrintDialog to get printer DC I am

  Zero CMyClass :: PrintReport () {CDC DC; CPrintDialog printDlg (FALSE); PrintDlg.GetDefaults (); :: DeleteDC (printDlg.m_pd.hDC); LPDEVMODE pDevMode = printDlg.GetDevMode (); if (pDevMode) {pDevMode- & gt; DmOrientation = DMORIENT_LANDSCAPE; :: GlobalUnlock (pDevMode); } HDC HDC; If ((hDC = printDlg.CreatePrinterDC ()) == NULL) {:: GlobalFree (printDlg.m_pd.hDevMode); :: GlobalFree (printDlg.m_pd.hDevNames); Return; } :: GlobalFree (printDlg.m_pd.hDevMode); :: GlobalFree (printDlg.m_pd.hDevNames); dc.Attach (HDC); // Attach a printer DC dc.m_bPrinting = TRUE; Dc.setMapMode (MM_LOENGLISH); / * Print Logic using DC * /}   

This works fine when I run my application in debug mode, which comes with an AA console application.

However, CPRIIDO is the creation when I fail to run the application as a Windows service.

Am I doing something wrong? :( Please help me.

Note: The application is designed to run in the installation as a service.

CPrintDialog creation is failing when I Run the application as a Windows service.) In a Windows service. Therefore, CPrintDialog is never going to work.

But you do not need to create a dialogue to get printer device references, assuming that you already know what printer you want to print. And since you are running as a non-interactive service, you already know this because should already know this, because there is no way that the user can choose printer.

To do this, call directly, specify the name of device and printer for "WINSPOOL" . By calculating the installed printer using the function, you can get the name of the desired printer. How is this easily documented for the article: / P>

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -