Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

(urgent)A problem getting printer info

Posted on 2002-06-16
3
Medium Priority
?
256 Views
Last Modified: 2013-11-20
Hi
I used EnumPrinters() with the PRINTER_INFO_2 structure to get information about all the printers in the system. However, when I tried to use DeviceCapabilities() with a name and a port from the array I received, the function returned -1. This may have something to do with the fact that I am using a network printer and I receive it's comment in the port field of the PRINTER_INFO_2 structure.
Could anyone please help me with this problem?
I use this code:
char* apStrings;
     int i,aRet;
     apStrings = new char[10000];
     aRet = DeviceCapabilities(mPrinterName,mPrinterPort,DC_PAPERNAMES,apStrings,NULL);
0
Comment
Question by:ICR
  • 2
3 Comments
 
LVL 16

Expert Comment

by:AlexNek
ID: 7084026
2 ICR
first go to link:
http://www.mvps.org/windev/ptk/enumprint.c

and then add code to loop:

          DWORD dwCount64;
          dwCount64 = DeviceCapabilities(lpInfo[dwItem].pPrinterName, lpInfo[dwItem].pPortName, DC_PAPERNAMES, NULL,NULL);

          LPTSTR pOutput;

          pOutput = new char[dwCount64*64];
          dwCount64 = DeviceCapabilities(lpInfo[dwItem].pPrinterName, lpInfo[dwItem].pPortName, DC_PAPERNAMES, pOutput,NULL);
          delete []pOutput;

It works for on my computer.
0
 

Author Comment

by:ICR
ID: 7088997
OK,it works, but now I can't figure out how to get the information from the pOutput buffer. Could you help me with that?
0
 
LVL 16

Accepted Solution

by:
AlexNek earned 300 total points
ID: 7090946
2 ICR
easy way, not recommended for general use

LPTSTR pPaperName;

for (DWORD i=0; i<dwCount64; i++){
   pPaperName = pOutput + i*64;
...
}

0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

916 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