Solved

Problem in Getting the Printer Status

Posted on 2000-03-20
3
582 Views
Last Modified: 2011-04-14
Hi,
   We are doing a VC++ applicatin in which we do a printing job also.
   We need to find out the printer status before the data is sent to Printer. For that we are opening the printer and getting the printer handle. Then using the GetPrinter we are getting the printer info of level 2. But the status of the printer is always shown as 0 only irrespective of the printer status. We have tried opening all the tays of the printer. We have tried giving a printer device name which doent exist at all.
    In all the cases the status is 0 only.
Please help us in this reagrd.
The sample code we are using is given below:

HANDLE hPrintHandle;
CString str = printDlg.GetDeviceName();
char* strName = str.GetBuffer(0);
if( !OpenPrinter(strName,&hPrintHandle,NULL) )
    AfxMessageBox( "Error in opening the print...");
str.ReleaseBuffer(-1);
      
PRINTER_INFO_2* printerInfo;
BYTE infoStruct;
DWORD dwNeeded;
BOOL b = GetPrinter( hPrintHandle,2, NULL,0,&dwNeeded );

DWORD err = GetLastError();

dwNeeded = dwNeeded + 4;
            
printerInfo = (PRINTER_INFO_2 *)malloc(dwNeeded);

if (!(printerInfo)) /* Failure to allocate memory. */
    return;
      
DWORD cByteUsed;

/* Get the printer information. */
if (!GetPrinter(hPrintHandle, 2,(LPBYTE)printerInfo,                                    dwNeeded,&cByteUsed) )
{
              /* Failure to access the printer. */
      free(printerInfo);
      printerInfo = NULL;
      return;
}
      
DWORD printerStatus = printerInfo->Status;//This value is  always coming as 0

Thanks in  advance
Madhura

0
Comment
Question by:Madhura122398
3 Comments
 
LVL 9

Accepted Solution

by:
Pacman earned 20 total points
ID: 2639960
There's a knowledge base article about getting printer status.
Read this:

http://support.microsoft.com/support/kb/articles/Q160/1/29.asp
0
 

Expert Comment

by:srenivas1976
ID: 7916834
I need a solution for finding the printer status
0
 

Expert Comment

by:sjjf
ID: 10378669
who has solved it ? can you help me ?
i am in trouble now .
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

930 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now