#include < WINDOWS.H > #include < winspool.h > #define DllExport __declspec( dllexport ) DllExport DWORD PrinterStatus(LPTSTR lpPrinter); DllExport DWORD PrinterStatus(LPTSTR lpPrinter) { DWORD iResult = -1; HGLOBAL hGlobal = NULL; LPHANDLE iHandle = 0; DWORD level = 2, numbytes = 0, dSize; PRINTER_INFO_2 *prninfo = NULL; if SUCCEEDED(OpenPrinter(lpPrinter, iHandle, NULL)) { /* Get the necessary size of the structure */ GetPrinter(iHandle, level, 0, 0, &numbytes); if (numbytes > 0) { /* Allocate memory for the structure */ hGlobal = GlobalAlloc(GHND, numbytes); if (hGlobal != NULL) { prninfo = (PRINTER_INFO_2 *)GlobalLock(hGlobal); /* Call GetPrinter */ if (prninfo != NULL) { dSize = sizeof(prninfo); GetPrinter(iHandle, level, (LPBYTE)prninfo, dSize, &numbytes); /* Set the return value */ iResult = prninfo->Status; /* Free the memory */ GlobalUnlock(hGlobal); } /* Release it */ GlobalFree(hGlobal); } } /* Close the printer */ ClosePrinter(iHandle); } return iResult; }It compiles fine, but I'm not certain that it's working correctly. When I change the assignment of the return value to: iResult = prninfo->Attributes, it always returns 0. In playing around with calls to GetPrinter() using the PRINTER_INFO_2 structure in VFP, I get a value back that seems to be correct from the tests I've conducted. Note that I've omitted the DLLMain from the code above.