[vdagent-win PATCH v4 16/19] Avoids to call supported_system_version()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The only reason we call this function is to check if the
system should support some APIs.
Instead just check directly if these APIs are supported
calling GetProcAddress directly.

Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
---
 vdagent/vdagent.cpp | 29 +++++++++++++++--------------
 1 file changed, 15 insertions(+), 14 deletions(-)

diff --git a/vdagent/vdagent.cpp b/vdagent/vdagent.cpp
index 631f27c..9a40388 100644
--- a/vdagent/vdagent.cpp
+++ b/vdagent/vdagent.cpp
@@ -269,21 +269,22 @@ bool VDAgent::run()
     if (!SetProcessShutdownParameters(0x100, 0)) {
         vd_printf("SetProcessShutdownParameters failed %lu", GetLastError());
     }
-    if (supported_system_version() == SYS_VER_WIN_7_CLASS) {
-        HMODULE _user_lib = GetModuleHandle(L"User32");
-        if (!_user_lib) {
-            vd_printf("GetModuleHandle failed %lu", GetLastError());
-            return false;
-        }
-        _add_clipboard_listener =
-            (PCLIPBOARD_OP)GetProcAddress(_user_lib, "AddClipboardFormatListener");
-        _remove_clipboard_listener =
-            (PCLIPBOARD_OP)GetProcAddress(_user_lib, "RemoveClipboardFormatListener");
-        if (!_add_clipboard_listener || !_remove_clipboard_listener) {
-            vd_printf("GetProcAddress failed %lu", GetLastError());
-            return false;
-        }
+
+    HMODULE _user_lib = GetModuleHandle(L"User32");
+    if (!_user_lib) {
+        vd_printf("GetModuleHandle failed %lu", GetLastError());
+        return false;
     }
+    _add_clipboard_listener =
+        (PCLIPBOARD_OP)GetProcAddress(_user_lib, "AddClipboardFormatListener");
+    _remove_clipboard_listener =
+        (PCLIPBOARD_OP)GetProcAddress(_user_lib, "RemoveClipboardFormatListener");
+    // do not use FormatListener APIs if not available
+    if (!_add_clipboard_listener || !_remove_clipboard_listener) {
+        _add_clipboard_listener = nullptr;
+        _remove_clipboard_listener = nullptr;
+    }
+
     if (!_control_event)
         _control_event = CreateEvent(NULL, FALSE, FALSE, NULL);
     if (!_control_event) {
-- 
2.17.1

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux Virtualization]     [Linux Virtualization]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]