Deskflow 1.22.0.197
Keyboard and mouse sharing utility
Loading...
Searching...
No Matches
MSWindowsHandle.h
Go to the documentation of this file.
1/*
2 * Deskflow -- mouse and keyboard sharing utility
3 * SPDX-FileCopyrightText: (C) 2025 Symless Ltd.
4 * SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
5 */
6
7#pragma once
8
9#include "base/Log.h"
10
11#define WIN32_LEAN_AND_MEAN
12#include <Windows.h>
13
18{
19public:
20 explicit MSWindowsHandle(HANDLE handle) : m_handle(handle)
21 {
22 }
23
28
30 {
31 if (m_handle == nullptr || m_handle == INVALID_HANDLE_VALUE) {
32 return;
33 }
34
35 if (!CloseHandle(m_handle)) {
36 LOG_WARN("failed to close handle");
37 }
38 }
39
40 HANDLE
41 get() const
42 {
43 return m_handle;
44 }
45
46private:
47 HANDLE m_handle = nullptr;
48};
#define LOG_WARN(...)
Definition Log.h:217
MSWindowsHandle(MSWindowsHandle &&)=delete
MSWindowsHandle & operator=(MSWindowsHandle &&)=delete
HANDLE get() const
Definition MSWindowsHandle.h:41
~MSWindowsHandle()
Definition MSWindowsHandle.h:29
MSWindowsHandle(const MSWindowsHandle &)=delete
MSWindowsHandle(HANDLE handle)
Definition MSWindowsHandle.h:20
MSWindowsHandle & operator=(const MSWindowsHandle &)=delete