Solved

DeviceCapabilities() buffer

Posted on 2002-06-18
3
389 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

867 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

18 Experts available now in Live!

Get 1:1 Help Now