Solved

(urgent)A problem getting printer info

Posted on 2002-06-16
3
238 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 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
dog bark java program 15 87
sum28 challenge 31 105
ShiftLeft challenge 21 76
Annoying "thing" blocks my view 4 81
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

914 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now