Solved

DeviceCapabilities() buffer

Posted on 2002-06-18
3
398 Views
Last Modified: 2013-11-20
Hi,
I have the following problem.I'm using DeviceCapabilities() to get the paper and tray names a printer supports. However, I can't figure out how to decipher the buffer I get. Could anyone give me a sample code?

Thanks in advance
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
3 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 7089373
Check out http://support.microsoft.com/default.aspx?scid=kb;EN-US;q81245 ("DeviceCapabilities Function Sample Code (Q81245)")
0
 

Author Comment

by:ICR
ID: 7089563
The information here is about how to use the function.I already know that. What I'm asking about, however, is how to use the buffer with the names of the papers/bins I receive - how to separate the names of the papers/bins from the single string I receive.
0
 
LVL 32

Accepted Solution

by:
jhance earned 45 total points
ID: 7089851
It seems pretty straightforward.  The SDK docs say about this:

"Retrieves the names of the printer's paper bins. The pOutput buffer receives an array of string buffers. Each string buffer is 24 characters long and contains the name of a paper bin. The return value indicates the number of entries in the array. The name strings are null-terminated unless the name is 24 characters long. If pOutput is NULL, the return value is the number of bin entries required."

So you have an array of N strings, all NULL terminated and starting 24 characters apart.  The function returns how many there are.

So basically you could do:

char r[25];

DWORD dwCount = DeviceCapabilities(etc...);
if(dwCount != 0xFFFFFFFF){
  p = pBuffer;
  for(DWORD i=0; i<dwCount; i++){
    memset(r, 0, 25);
    memcpy(r, p, 24);
    AfxMessageBox(r, MB_OK);
    p += 24;
  }
}
else{
  // ERROR!!!
}
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
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.
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 …

752 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