MegaBites-AI/Windows-powershell
0372
1// Copyright (c) Microsoft Corporation.2// Licensed under the MIT License.3 4using System;5using System.Runtime.InteropServices;6 7namespace Microsoft.Powershell.Commands.GetCounter.PdhNative8{9 internal sealed class PdhSafeDataSourceHandle : SafeHandle10 {11 private PdhSafeDataSourceHandle() : base(IntPtr.Zero, true) { }12 13 public override bool IsInvalid14 {15 get16 {17 return handle == IntPtr.Zero;18 }19 }20 21 protected override bool ReleaseHandle()22 {23 return (PdhHelper.PdhCloseLog(handle, 0) == 0);24 }25 }26 27 internal sealed class PdhSafeQueryHandle : SafeHandle28 {29 private PdhSafeQueryHandle() : base(IntPtr.Zero, true) { }30 31 public override bool IsInvalid32 {33 get34 {35 return handle == IntPtr.Zero;36 }37 }38 39 protected override bool ReleaseHandle()40 {41 return (PdhHelper.PdhCloseQuery(handle) == 0);42 }43 }44 45 internal sealed class PdhSafeLogHandle : SafeHandle46 {47 private PdhSafeLogHandle() : base(IntPtr.Zero, true) { }48 49 public override bool IsInvalid50 {51 get52 {53 return handle == IntPtr.Zero;54 }55 }56 57 protected override bool ReleaseHandle()58 {59 return (PdhHelper.PdhCloseLog(handle, 0) == 0);60 }61 }62}63 