1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef REMOTING_BASE_SCOPED_SC_HANDLE_WIN_H_ 6 #define REMOTING_BASE_SCOPED_SC_HANDLE_WIN_H_ 7 8 #include <windows.h> 9 10 #include "base/win/scoped_handle.h" 11 12 namespace remoting { 13 14 class ScHandleTraits { 15 public: 16 typedef SC_HANDLE Handle; 17 18 // Closes the handle. CloseHandle(SC_HANDLE handle)19 static bool CloseHandle(SC_HANDLE handle) { 20 return ::CloseServiceHandle(handle) != FALSE; 21 } 22 23 // Returns true if the handle value is valid. IsHandleValid(SC_HANDLE handle)24 static bool IsHandleValid(SC_HANDLE handle) { 25 return handle != NULL; 26 } 27 28 // Returns NULL handle value. NullHandle()29 static SC_HANDLE NullHandle() { 30 return NULL; 31 } 32 33 private: 34 DISALLOW_IMPLICIT_CONSTRUCTORS(ScHandleTraits); 35 }; 36 37 typedef base::win::GenericScopedHandle< 38 ScHandleTraits, base::win::DummyVerifierTraits> ScopedScHandle; 39 40 } // namespace remoting 41 42 #endif // REMOTING_BASE_SCOPED_SC_HANDLE_WIN_H_ 43