Coomand-line tool to list shared printers :
#include <windows.h>
#include <winspool.h>
#include <stdio.h>
int main(int argc, char * argv[]) {
DWORD cbBuf = 0;
DWORD pcReturned;
PRINTER_INFO_2 * prinfo;
BOOL r;
int rv = 0;
DWORD i;
char * err = "The EnumPrinters API could not retrieve printer information.\n";
if (argc != 2) {
printf("ListPrinters V1.0 by Vortex\n\nUsage : ListPrinters \\\\server\n");
return 1;
}
EnumPrinters(PRINTER_ENUM_SHARED | PRINTER_ENUM_NAME, argv[1], 2, NULL, 0, & cbBuf, & pcReturned);
if (!cbBuf) {
printf("%s", err);
return 2;
}
prinfo = (PRINTER_INFO_2 * )VirtualAlloc(0, cbBuf, MEM_COMMIT, PAGE_READWRITE);
if (!prinfo) {
printf("Memory allocation failed.\n");
return 3;
}
r = EnumPrinters(PRINTER_ENUM_SHARED | PRINTER_ENUM_NAME, argv[1], 2, (LPBYTE) prinfo, cbBuf, & cbBuf, & pcReturned);
if (!r) {
printf("%s", err);
rv = 2;
} else {
for (i = 0; i < pcReturned; ++i) {
printf("%s\n", prinfo[i].pShareName);
}
}
VirtualFree(prinfo, 0, MEM_RELEASE);
return rv;
}