diff --git a/include/WinStd/Win.h b/include/WinStd/Win.h index 601f3b0c..b0dfe5f1 100644 --- a/include/WinStd/Win.h +++ b/include/WinStd/Win.h @@ -2192,6 +2192,37 @@ namespace winstd } }; + /// + /// SC_HANDLE wrapper class + /// + class sc_handle : public handle + { + WINSTD_HANDLE_IMPL(sc_handle, NULL) + + public: + /// + /// Closes an open object handle. + /// + /// \sa [CloseServiceHandle function](https://docs.microsoft.com/en-us/windows/win32/api/winsvc/nf-winsvc-closeservicehandle) + /// + virtual ~sc_handle() + { + if (m_h != invalid) + free_internal(); + } + + protected: + /// + /// Closes an open object handle. + /// + /// \sa [CloseServiceHandle function](https://docs.microsoft.com/en-us/windows/win32/api/winsvc/nf-winsvc-closeservicehandle) + /// + void free_internal() noexcept override + { + CloseServiceHandle(m_h); + } + }; + /// @} }