Solved

(urgent)A problem getting printer info

Posted on 2002-06-16
3
245 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
[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
  • 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 75 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

Get MySQL database support online, now!

At Percona’s web store you can order your MySQL database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card.

Question has a verified solution.

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

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

635 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