Solved

DeviceCapabilities() buffer

Posted on 2002-06-18
3
383 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
3 Comments
 
LVL 86

Expert Comment

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

Author Comment

by:ICR
Comment Utility
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
Comment Utility
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
paragon account problem 9 96
Folder Comparison 12 52
Separate files macro - Errors on larger data set 18 56
if loop in java 3 114
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…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

771 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

10 Experts available now in Live!

Get 1:1 Help Now