summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
bf133a7)
apparently tries less hard to find printers so won't slow the system down.
Tested on 2000 and 98; in both cases printer enumeration and printing worked
as well as they did in 2003-08-21.
Made a single shared copy of osVersion in winmisc.c so that printing.c can
find it. Made other users (window.c, pageant.c) use this copy.
git-svn-id: svn://svn.tartarus.org/sgt/putty@3411
cda61777-01e9-0310-a592-
d414129be87e
{
WNDCLASS wndclass;
MSG msg;
{
WNDCLASS wndclass;
MSG msg;
HMODULE advapi;
char *command = NULL;
int added_keys = 0;
HMODULE advapi;
char *command = NULL;
int added_keys = 0;
* Determine whether we're an NT system (should have security
* APIs) or a non-NT system (don't do security).
*/
* Determine whether we're an NT system (should have security
* APIs) or a non-NT system (don't do security).
*/
- memset(&osi, 0, sizeof(OSVERSIONINFO));
- osi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
- if (GetVersionEx(&osi) && osi.dwPlatformId == VER_PLATFORM_WIN32_NT) {
+ if (!init_winver())
+ {
+ modalfatalbox("Windows refuses to report a version");
+ }
+ if (osVersion.dwPlatformId == VER_PLATFORM_WIN32_NT) {
has_security = TRUE;
} else
has_security = FALSE;
has_security = TRUE;
} else
has_security = FALSE;
#include <windows.h>
#include "putty.h"
#include <windows.h>
#include "putty.h"
-
-/*
- * Boggle. Flipping between the two branches of this #if appears to
- * make all the difference as to whether network printers show up
- * under PRINTER_ENUM_CONNECTIONS on NT 4. I don't pretend to
- * understand this...
- */
-#if 0
-#define ENUM_LEVEL 5
-#define ENUM_PTR LPPRINTER_INFO_5
-#define ENUM_TYPE PRINTER_INFO_5
-#define ENUM_MEMBER pPrinterName
-#else
-#define ENUM_LEVEL 1
-#define ENUM_PTR LPPRINTER_INFO_1
-#define ENUM_TYPE PRINTER_INFO_1
-#define ENUM_MEMBER pName
-#endif
struct printer_enum_tag {
int nprinters;
struct printer_enum_tag {
int nprinters;
+ DWORD enum_level;
+ union {
+ LPPRINTER_INFO_4 i4;
+ LPPRINTER_INFO_5 i5;
+ } info;
};
struct printer_job_tag {
HANDLE hprinter;
};
};
struct printer_job_tag {
HANDLE hprinter;
};
-static char *printer_add_enum(int param, char *buffer,
+static char *printer_add_enum(int param, DWORD level, char *buffer,
int offset, int *nprinters_ptr)
{
DWORD needed, nprinters;
int offset, int *nprinters_ptr)
{
DWORD needed, nprinters;
* we'll need for the output. Discard the return value since it
* will almost certainly be a failure due to lack of space.
*/
* 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,
+ EnumPrinters(param, NULL, level, buffer+offset, 512,
&needed, &nprinters);
if (needed < 512)
&needed, &nprinters);
if (needed < 512)
buffer = sresize(buffer, offset+needed, char);
buffer = sresize(buffer, offset+needed, char);
- if (EnumPrinters(param, NULL, ENUM_LEVEL, buffer+offset,
+ if (EnumPrinters(param, NULL, level, buffer+offset,
needed, &needed, &nprinters) == 0)
return NULL;
needed, &needed, &nprinters) == 0)
return NULL;
*nprinters_ptr = 0; /* default return value */
buffer = snewn(512, char);
*nprinters_ptr = 0; /* default return value */
buffer = snewn(512, char);
+ /*
+ * Determine what enumeration level to use.
+ * When enumerating printers, we need to use PRINTER_INFO_4 on
+ * NT-class systems to avoid Windows looking too hard for them and
+ * slowing things down; and we need to avoid PRINTER_INFO_5 as
+ * we've seen network printers not show up.
+ * On 9x-class systems, PRINTER_INFO_4 isn't available and
+ * PRINTER_INFO_5 is recommended.
+ * Bletch.
+ */
+ if (osVersion.dwPlatformId != VER_PLATFORM_WIN32_NT) {
+ ret->enum_level = 5;
+ } else {
+ ret->enum_level = 4;
+ }
+
retval = printer_add_enum(PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS,
retval = printer_add_enum(PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS,
- buffer, 0, nprinters_ptr);
+ ret->enum_level, buffer, 0, nprinters_ptr);
if (!retval)
goto error;
else
buffer = retval;
if (!retval)
goto error;
else
buffer = retval;
- ret->info = (ENUM_PTR)buffer;
+ switch (ret->enum_level) {
+ case 4:
+ ret->info.i4 = (LPPRINTER_INFO_4)buffer;
+ break;
+ case 5:
+ ret->info.i5 = (LPPRINTER_INFO_5)buffer;
+ break;
+ }
ret->nprinters = *nprinters_ptr;
return ret;
ret->nprinters = *nprinters_ptr;
return ret;
return NULL;
if (i < 0 || i >= pe->nprinters)
return NULL;
return NULL;
if (i < 0 || i >= pe->nprinters)
return NULL;
- return pe->info[i].ENUM_MEMBER;
+ switch (pe->enum_level) {
+ case 4:
+ return pe->info.i4[i].pPrinterName;
+ case 5:
+ return pe->info.i5[i].pPrinterName;
+ default:
+ return NULL;
+ }
}
void printer_finish_enum(printer_enum *pe)
{
if (!pe)
return;
}
void printer_finish_enum(printer_enum *pe)
{
if (!pe)
return;
+ switch (pe->enum_level) {
+ case 4:
+ sfree(pe->info.i4);
+ break;
+ case 5:
+ sfree(pe->info.i5);
+ break;
+ }
static int wsa_started = 0;
static int wsa_started = 0;
-static OSVERSIONINFO osVersion;
-
static UINT wm_mousewheel = WM_MOUSEWHEEL;
/* Dummy routine, only required in plink. */
static UINT wm_mousewheel = WM_MOUSEWHEEL;
/* Dummy routine, only required in plink. */
* config box. */
defuse_showwindow();
* config box. */
defuse_showwindow();
- ZeroMemory(&osVersion, sizeof(osVersion));
- osVersion.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
- if (!GetVersionEx ( (OSVERSIONINFO *) &osVersion)) {
- char *str = dupprintf("%s Fatal Error", appname);
- MessageBox(NULL, "Windows refuses to report a version",
- str, MB_OK | MB_ICONEXCLAMATION);
- sfree(str);
- return 1;
- }
+ char *str = dupprintf("%s Fatal Error", appname);
+ MessageBox(NULL, "Windows refuses to report a version",
+ str, MB_OK | MB_ICONEXCLAMATION);
+ sfree(str);
+ return 1;
#include "putty.h"
#include "winstuff.h"
#include "putty.h"
#include "winstuff.h"
+OSVERSIONINFO osVersion;
+
void platform_get_x11_auth(char *display, int *proto,
unsigned char *data, int *datalen)
{
void platform_get_x11_auth(char *display, int *proto,
unsigned char *data, int *datalen)
{
SetWindowLong(hwnd, BOXFLAGS, DF_END);
}
SetWindowLong(hwnd, BOXFLAGS, DF_END);
}
+BOOL init_winver(void)
+{
+ ZeroMemory(&osVersion, sizeof(osVersion));
+ osVersion.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
+ return GetVersionEx ( (OSVERSIONINFO *) &osVersion);
+}
+
#ifdef DEBUG
static FILE *debug_fp = NULL;
static HANDLE debug_hdl = INVALID_HANDLE_VALUE;
#ifdef DEBUG
static FILE *debug_fp = NULL;
static HANDLE debug_hdl = INVALID_HANDLE_VALUE;
void SaneEndDialog(HWND hwnd, int ret);
void SaneEndDialog(HWND hwnd, int ret);
+extern OSVERSIONINFO osVersion;
+BOOL init_winver(void);
+
/*
* Exports from sizetip.c.
*/
/*
* Exports from sizetip.c.
*/