Solved

Problem in Getting the Printer Status

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
returning a dereferenced pts in C++ 10 158
FMX StringGrid1->Canvas->FillRect Problem 3 170
typedef std::deque<BYTE> ByteVector is broken in vs2012 23 87
Find Visual Studio Tools 2 111
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
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 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.

809 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