Solved

(urgent)A problem getting printer info

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
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…
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.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

747 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

12 Experts available now in Live!

Get 1:1 Help Now