зеркало из https://github.com/github/putty.git
After trying a succession of tests on Jacob's machine, I think I've
finally isolated the _important_ difference between Romano Trampus's working printing.c and my failing one: he ignores the error return from the first exploratory how-big-does-my-buffer-need-to-be call to EnumPrinters(), because not having enough buffer space counts as an error condition. Hence I am officially a klutz, but this should now work. (Also reverted ENUM_LEVEL to 1, again, because that seems to be the choice of people whose code works.) [originally from svn r1915]
This commit is contained in:
Родитель
9ccb502c47
Коммит
6813094751
12
printing.c
12
printing.c
|
@ -11,7 +11,7 @@
|
||||||
* under PRINTER_ENUM_CONNECTIONS on NT 4. I don't pretend to
|
* under PRINTER_ENUM_CONNECTIONS on NT 4. I don't pretend to
|
||||||
* understand this...
|
* understand this...
|
||||||
*/
|
*/
|
||||||
#if 1
|
#if 0
|
||||||
#define ENUM_LEVEL 5
|
#define ENUM_LEVEL 5
|
||||||
#define ENUM_PTR LPPRINTER_INFO_5
|
#define ENUM_PTR LPPRINTER_INFO_5
|
||||||
#define ENUM_TYPE PRINTER_INFO_5
|
#define ENUM_TYPE PRINTER_INFO_5
|
||||||
|
@ -39,9 +39,13 @@ static char *printer_add_enum(int param, char *buffer,
|
||||||
|
|
||||||
buffer = srealloc(buffer, offset+512);
|
buffer = srealloc(buffer, offset+512);
|
||||||
|
|
||||||
if (EnumPrinters(param, NULL, ENUM_LEVEL, buffer+offset,
|
/*
|
||||||
512, &needed, &nprinters) == 0)
|
* Exploratory call to EnumPrinters to determine how much space
|
||||||
return NULL;
|
* we'll need for the output. Discard the return value since it
|
||||||
|
* will almost certainly be a failure due to lack of space.
|
||||||
|
*/
|
||||||
|
EnumPrinters(param, NULL, ENUM_LEVEL, buffer+offset, 512,
|
||||||
|
&needed, &nprinters);
|
||||||
|
|
||||||
if (needed < 512)
|
if (needed < 512)
|
||||||
needed = 512;
|
needed = 512;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче