[Spice-devel] [vdagent-win PATCH v6] Use GetModuleHandle to get some functions from user32 library
Christophe Fergeau
cfergeau at redhat.com
Thu Jul 19 09:37:12 UTC 2018
Still unconvinced about that one ;)
But
Acked-by: Christophe Fergeau <cfergeau at redhat.com>
if you feel this is the way to go.
Christophe
On Wed, Jul 18, 2018 at 11:52:45AM +0100, Frediano Ziglio wrote:
> The library is surely already loaded as providing clipboard and
> other utilities we need.
> user32 is one of the main win32 libraries.
> Avoid using LoadLibrary that increment the reference so we don't
> need to call FreeLibrary to cleanly decrement the reference.
>
> Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
> ---
> vdagent/vdagent.cpp | 7 ++-----
> 1 file changed, 2 insertions(+), 5 deletions(-)
>
> Changes since previous version:
> - rebased.
>
> diff --git a/vdagent/vdagent.cpp b/vdagent/vdagent.cpp
> index e577679..f3d60c7 100644
> --- a/vdagent/vdagent.cpp
> +++ b/vdagent/vdagent.cpp
> @@ -125,7 +125,6 @@ private:
> static VDAgent* _singleton;
> HWND _hwnd;
> HWND _hwnd_next_viewer;
> - HMODULE _user_lib;
> PCLIPBOARD_OP _add_clipboard_listener;
> PCLIPBOARD_OP _remove_clipboard_listener;
> clipboard_owner_t _clipboard_owner;
> @@ -183,7 +182,6 @@ VDAgent* VDAgent::get()
> VDAgent::VDAgent()
> : _hwnd (NULL)
> , _hwnd_next_viewer (NULL)
> - , _user_lib (NULL)
> , _add_clipboard_listener (NULL)
> , _remove_clipboard_listener (NULL)
> , _clipboard_owner (owner_none)
> @@ -222,7 +220,6 @@ VDAgent::VDAgent()
>
> VDAgent::~VDAgent()
> {
> - FreeLibrary(_user_lib);
> close_vio_serial();
> CloseHandle(_stop_event);
> CloseHandle(_control_event);
> @@ -280,9 +277,9 @@ bool VDAgent::run()
> vd_printf("SetProcessShutdownParameters failed %lu", GetLastError());
> }
>
> - _user_lib = LoadLibrary(L"User32.dll");
> + HMODULE _user_lib = GetModuleHandle(L"User32");
> if (!_user_lib) {
> - vd_printf("LoadLibrary failed %lu", GetLastError());
> + vd_printf("GetModuleHandle failed %lu", GetLastError());
> return false;
> }
> _add_clipboard_listener =
> --
> 2.17.1
>
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20180719/3da635ee/attachment.sig>
More information about the Spice-devel
mailing list