ID Number: Q82167
3.10
WINDOWS
Summary:
When an application calls the DeviceCapabilities function with the
nIndex parameter set to DC_BINNAMES, 24 bytes are required for each
bin name.
The DeviceCapabilities function returns the name of each bin as a
null-terminated string in a character array. Each bin-name entry
requires 24 bytes and begins on the [(n-1) * 24] byte of the array.
The following code demonstrates how to allocate a block of memory,
retrieve the bin names, and walk through the array of bin names. The
code assumes that GetProcAddress has been used to retrieve a long
pointer to the DeviceCapabilities function in the printer driver and
that the pointer was stored in the lpfnDevCap variable:
if ((dwDMSize = (*lpfnDevCap)(lpszDevice, lpszPort, DC_BINNAMES,
0L, lpDevMode))
&& (dwDMSize != (DWORD)(-1)))
{
if (hMem = GlobalAlloc(GMEM_MOVEABLE, (WORD)dwDMSize * 24))
{
lpMem = (LPINT)GlobalLock(hMem);
nBins = (WORD)(*lpfnDevCap)(lpszDevice, lpszPort,
DC_BINNAMES, lpMem, lpDevMode);
for (lpBins = lpMem, i = 0; i < nBins; i++, lpBins += 24)
{
// lpBins points to the null-terminated bin name.
}
GlobalUnlock(hMem);
GlobalFree(hMem);
}
}
Additional reference words: 3.10