Solved

Problem in Getting the Printer Status

Posted on 2000-03-20
3
579 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

747 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

12 Experts available now in Live!

Get 1:1 Help Now