Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Problem in Getting the Printer Status

Posted on 2000-03-20
3
Medium Priority
?
621 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 9

Accepted Solution

by:
Pacman earned 60 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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone 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

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…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
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.
Suggested Courses

597 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