Solved

Problem in Getting the Printer Status

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Handle Exceptions during instantiation 28 416
returning a dereferenced pts in C++ 10 149
C++ question 3 65
Installshield for Embarcadero EX 10.1 Berlin 4 42
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

810 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