I can't tell you how much I appreciate your help (algorism especially).
I finally got this thing to return a list of printer feeders in an array to the Web page.
Again, it's PHP7 so I'm stuck inside a rather complex framework.
Here's the last part for future reference:
Code:
#define BNLEN 24
FILE *fp;
DWORD dcRet;
char (*pOut)[BNLEN]; // ptr to dynam array of 24-element char arrays
// Get number of bin names.
dcRet = DeviceCapabilities(resource->name, pi2->pPortName, DC_BINNAMES, NULL, NULL); // or pi2->pDevMode
if (dcRet == (DWORD)-1){
sprintf(sRtn, "DeviceCapabilities failed: %u\n", GetLastError());
RETURN_STRING(sRtn, 1);
}
// Alloc and fill bin names.
pOut = emalloc(dcRet * BNLEN);
dcRet = DeviceCapabilities(resource->name, pi2->pPortName, DC_BINNAMES, (LPTSTR)pOut, NULL); // or pi2->pDevMode
if (dcRet == (DWORD)-1){
sprintf(sRtn, "DeviceCapabilities failed: %u\n", GetLastError());
RETURN_STRING(sRtn, 1);
}
if(array_init(return_value) == FAILURE) RETURN_FALSE;
for (DWORD i = 0; i < dcRet; i++) {
add_index_string(return_value, i, pOut[i]);
}