diff --git a/tshark.c b/tshark.c index bb40c5a07a..b761c7270b 100644 --- a/tshark.c +++ b/tshark.c @@ -66,6 +66,7 @@ #include #include #include +#include #include "globals.h" #include @@ -895,7 +896,7 @@ check_capture_privs(void) { #ifdef _WIN32 load_wpcap(); /* Warn the user if npf.sys isn't loaded. */ - if (!npf_sys_is_running() && get_os_major_version() >= 6) { + if (!npf_sys_is_running() && get_windows_major_version() >= 6) { fprintf(stderr, "The NPF driver isn't running. You may have trouble " "capturing or\nlisting interfaces.\n"); } diff --git a/ui/gtk/main.c b/ui/gtk/main.c index 231d4919a4..1d29eb2402 100644 --- a/ui/gtk/main.c +++ b/ui/gtk/main.c @@ -63,6 +63,7 @@ #include #include #include +#include #include @@ -2100,7 +2101,7 @@ check_and_warn_user_startup(gchar *cf_name _U_) #ifdef _WIN32 /* Warn the user if npf.sys isn't loaded. */ - if (!get_stdin_capture() && !cf_name && !npf_sys_is_running() && recent.privs_warn_if_no_npf && get_os_major_version() >= 6) { + if (!get_stdin_capture() && !cf_name && !npf_sys_is_running() && recent.privs_warn_if_no_npf && get_windows_major_version() >= 6) { priv_warning_dialog = simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK, "The NPF driver isn't running. You may have trouble\n" "capturing or listing interfaces."); diff --git a/version_info.c b/version_info.c index f7376505a0..7ed06c511a 100644 --- a/version_info.c +++ b/version_info.c @@ -40,10 +40,6 @@ #include "version.h" -#ifdef _WIN32 -#include -#endif - #ifdef HAVE_LIBCAP # include #endif @@ -219,23 +215,6 @@ get_runtime_version_info(GString *str, void (*additional_info)(GString *)) end_string(str); } -#if defined(_WIN32) -/* - * Get the major OS version. - */ -/* XXX - Should this return the minor version as well, e.g. 0x00050002? */ -guint32 -get_os_major_version() -{ - OSVERSIONINFO info; - info.dwOSVersionInfoSize = sizeof info; - if (GetVersionEx(&info)) { - return info.dwMajorVersion; - } - return 0; -} -#endif - /* * Editor modelines * diff --git a/version_info.h b/version_info.h index 53cc651909..0389fda407 100644 --- a/version_info.h +++ b/version_info.h @@ -56,13 +56,6 @@ void get_compiled_version_info(GString *str, void get_runtime_version_info(GString *str, void (*additional_info)(GString *)); -#if defined(_WIN32) -/* - * Get the major OS version. - */ -guint32 get_os_major_version(); -#endif - #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/wsutil/os_version_info.c b/wsutil/os_version_info.c index ba91b4163d..e72ee7f990 100644 --- a/wsutil/os_version_info.c +++ b/wsutil/os_version_info.c @@ -476,3 +476,27 @@ get_os_version_info(GString *str) g_string_append(str, "an unknown OS"); #endif } + +#if defined(_WIN32) +/* + * Get the Windows major OS version. + * + * XXX - Should this return the minor version as well, e.g. 0x00050002? + * + * XXX - I think Microsoft have now stuck it at 6 forever, so it really + * distinguishes, on the versions of Windows we currently support and + * future Windows versions between Windows 2000/XP (major version 5) and + * everything after it (major version 6). + */ +guint32 +get_windows_major_version(void) +{ + OSVERSIONINFO info; + + info.dwOSVersionInfoSize = sizeof info; + if (GetVersionEx(&info)) { + return info.dwMajorVersion; + } + return 0; +} +#endif diff --git a/wsutil/os_version_info.h b/wsutil/os_version_info.h index e493f49bb5..83211dd238 100644 --- a/wsutil/os_version_info.h +++ b/wsutil/os_version_info.h @@ -34,6 +34,13 @@ extern "C" { */ WS_DLL_PUBLIC void get_os_version_info(GString *str); +#ifdef _WIN32 +/* + * Get the Windows major OS version. + */ +WS_DLL_PUBLIC guint32 get_windows_major_version(void); +#endif + #ifdef __cplusplus } #endif /* __cplusplus */