Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

DeviceCapabilities() buffer

Posted on 2002-06-18
3
Medium Priority
?
404 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 135 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

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

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

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

688 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