Am Dienstag, den 11.10.2005, 10:36 +0200 schrieb Jonathan Ernst: -- cut -- + + EnumPrintersA(PRINTER_ENUM_LOCAL, NULL, 2, NULL, 0, &needed, &num); + if(num == 0) + { + -- cut --
Sorry that didn't work. You receive in "num" the Number of returned PRINTER_INFO_2 Entries in "buffer" Since "buffer" is NULL, "num" is always 0. Working Example from my Patch: ( http://www.winehq.org/pipermail/wine-patches/2005-October/021268.html ) + /* Verify, that we have a Printer installed */ + /* this will fail in wine, when you deleted your printer */ + + numentries = 0; + size = 0; + result = pEnumPrintersA(PRINTER_ENUM_LOCAL, + NULL, 2, NULL, 0, &size, &numentries); + + if (size == 0) + { + result = pEnumPrintersA(PRINTER_ENUM_CONNECTIONS, + NULL, 2, NULL, 0, &size, &numentries); + } + -- cut -- size == 0: no Printer installed size > 0: one or more Printers installed -- By By ... ... Detlef
D:\>printer --level 2 --flags 2 -v EnumPrintersA 00000002: selected flags: 2 00000002: : PRINTER_ENUM_LOCAL 00000002: selected level: 2 77d574b1: "winspool.drv",pEnumPrintersA 0000007a: (122) GetLastError() "The data area passed to a system call is toosmall." 00000000: EnumPrintersA(0x00000002, --NULL--, 2, NULL, 0, 0012ff68, 0012ff60) 0012ff68: (*LPDWORD) pNeeded= 0x000001f8 (504) 0012ff60: (*LPDWORD) pReturned= 0x00000000 (0) 00000001: EnumPrintersA(0x00000002, --NULL--, 2, 00142a40, 504, 0012ff68) 0012ff68: (*LPDWORD) pNeeded= 0x000001f8 (504) 0012ff60: (*LPDWORD) pReturned= 0x00000001 (1) 00142c38: Buffer-Overflow-Check: "OK" 00142a40: PRINTER_INFO_2 #1 00000000: .pServerName : --NULL-- 00142c26: .pPrinterName : "Nur_Text" 00142c24: .pShareName : "" 00142c18: .pPortName : "FILE:" 00142bf0: .pDriverName : "Generic / Text Only" 00142bb6: .pComment : "Generic / Text Only on FILE:" 00142bb4: .pLocation : "" 00000000: .pDevMode : 00142bb2: .pSepFile : "" 00142ba0: .pPrintProcessor: "winprint" 00142b98: .pDatatype : "RAW" 00142b96: .pParameters : "" 00000000: .pSecurityDescriptor: 00000040: .Attributes : 64 00000040: : PRINTER_ATTRIBUTE_LOCAL 00000001: .Priority : 1 00000000: .DefaultPriority: 0 00000000: .StartTime : 0 00000000: .UntilTime : 0 00000000: .Status : 0 00000000: .cJobs : 0 00000000: .AveragePPM : 0 normal exit