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
Solved

(urgent)A problem getting printer info

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

Suggested Solutions

Title # Comments Views Activity
how do i create updater to My Activex application? 3 94
no14 challenge 14 70
Message not shown 5 66
Way to decrease size of apk file 9 86
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

792 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