#include #include #include #include BYTE Buffer[4096*4]; int _cdecl wmain( int argc, WCHAR *argv[] ) { DWORD cb; DWORD cnt; DWORD i; PPRINTER_INFO_1 PrinterInfo = (PPRINTER_INFO_1) Buffer; PDRIVER_INFO_2 DriverInfo = (PDRIVER_INFO_2) Buffer; PPRINTPROCESSOR_INFO_1 ProcessorInfo = (PPRINTPROCESSOR_INFO_1) Buffer; PMONITOR_INFO_2 MonitorInfo = (PMONITOR_INFO_2) Buffer; PPORT_INFO_2 PortInfo = (PPORT_INFO_2) Buffer; if (argc >= 3) { if (argv[1][0] == L'-' && argv[1][1] == L'd' && argv[1][2] == L'd') { if (!DeletePrinterDriver( NULL, NULL, argv[2] )) { _tprintf( TEXT("DeletePrinterDriver() failed, ec=%d\n"), GetLastError() ); } return 0; } if (argv[1][0] == L'-' && argv[1][1] == L'd' && argv[1][2] == L'p') { HANDLE hPrinter; PRINTER_DEFAULTS PrinterDefaults; PrinterDefaults.pDatatype = NULL; PrinterDefaults.pDevMode = NULL; PrinterDefaults.DesiredAccess = PRINTER_ALL_ACCESS; OpenPrinter( argv[2], &hPrinter, &PrinterDefaults ); DeletePrinter( hPrinter ); ClosePrinter( hPrinter ); return 0; } if (argv[1][0] == L'-' && argv[1][1] == L'd' && argv[1][2] == L'c') { DeletePrinterConnection( argv[2] ); Sleep(3000); return 0; } if (argv[1][0] == L'-' && argv[1][1] == L'd' && argv[1][2] == L'm') { DeleteMonitor( NULL, NULL, argv[2] ); return 0; } if (argv[1][0] == L'-' && argv[1][1] == L'a' && argv[1][2] == L'm') { MONITOR_INFO_2 MonitorInfo; MonitorInfo.pName = argv[2]; MonitorInfo.pEnvironment = NULL; MonitorInfo.pDLLName = argv[3]; AddMonitor( NULL, 2, (LPBYTE) &MonitorInfo ); return 0; } } if (!EnumPrinters( PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS, NULL, 1, Buffer, sizeof(Buffer), &cb, &cnt )) { _tprintf( TEXT("EnumPrinters() failed, ec=0x%08x\n"), GetLastError() ); return -1; } if (cnt) { _tprintf( TEXT("\nPrinters:\n") ); for (i=0; i