Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / ndp / clr / src / BCL / Microsoft / Win32 / SafeHandles / Win32SafeHandles.cs / 1 / Win32SafeHandles.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== // // Abstract derivations of SafeHandle designed to provide the common // functionality supporting Win32 handles. More specifically, they describe how // an invalid handle looks (for instance, some handles use -1 as an invalid // handle value, others use 0). // // Further derivations of these classes can specialise this even further (e.g. // file or registry handles). // // using System; using System.Runtime.InteropServices; using System.Runtime.CompilerServices; using System.Security.Permissions; using System.Runtime.ConstrainedExecution; namespace Microsoft.Win32.SafeHandles { // Class of safe handle which uses 0 or -1 as an invalid handle. [SecurityPermission(SecurityAction.InheritanceDemand, UnmanagedCode=true)] [SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode=true)] public abstract class SafeHandleZeroOrMinusOneIsInvalid : SafeHandle { [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] protected SafeHandleZeroOrMinusOneIsInvalid(bool ownsHandle) : base(IntPtr.Zero, ownsHandle) { } public override bool IsInvalid { get { return handle.IsNull() || handle == new IntPtr(-1); } } } // Class of safe handle which uses only -1 as an invalid handle. [SecurityPermission(SecurityAction.InheritanceDemand, UnmanagedCode=true)] [SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode=true)] public abstract class SafeHandleMinusOneIsInvalid : SafeHandle { [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] protected SafeHandleMinusOneIsInvalid(bool ownsHandle) : base(new IntPtr(-1), ownsHandle) { } public override bool IsInvalid { get { return handle == new IntPtr(-1); } } } // Class of critical handle which uses 0 or -1 as an invalid handle. [SecurityPermission(SecurityAction.InheritanceDemand, UnmanagedCode=true)] [SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode=true)] public abstract class CriticalHandleZeroOrMinusOneIsInvalid : CriticalHandle { [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] protected CriticalHandleZeroOrMinusOneIsInvalid() : base(IntPtr.Zero) { } public override bool IsInvalid { get { return handle.IsNull() || handle == new IntPtr(-1); } } } // Class of critical handle which uses only -1 as an invalid handle. [SecurityPermission(SecurityAction.InheritanceDemand, UnmanagedCode=true)] [SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode=true)] public abstract class CriticalHandleMinusOneIsInvalid : CriticalHandle { [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] protected CriticalHandleMinusOneIsInvalid() : base(new IntPtr(-1)) { } public override bool IsInvalid { get { return handle == new IntPtr(-1); } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== // // Abstract derivations of SafeHandle designed to provide the common // functionality supporting Win32 handles. More specifically, they describe how // an invalid handle looks (for instance, some handles use -1 as an invalid // handle value, others use 0). // // Further derivations of these classes can specialise this even further (e.g. // file or registry handles). // // using System; using System.Runtime.InteropServices; using System.Runtime.CompilerServices; using System.Security.Permissions; using System.Runtime.ConstrainedExecution; namespace Microsoft.Win32.SafeHandles { // Class of safe handle which uses 0 or -1 as an invalid handle. [SecurityPermission(SecurityAction.InheritanceDemand, UnmanagedCode=true)] [SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode=true)] public abstract class SafeHandleZeroOrMinusOneIsInvalid : SafeHandle { [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] protected SafeHandleZeroOrMinusOneIsInvalid(bool ownsHandle) : base(IntPtr.Zero, ownsHandle) { } public override bool IsInvalid { get { return handle.IsNull() || handle == new IntPtr(-1); } } } // Class of safe handle which uses only -1 as an invalid handle. [SecurityPermission(SecurityAction.InheritanceDemand, UnmanagedCode=true)] [SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode=true)] public abstract class SafeHandleMinusOneIsInvalid : SafeHandle { [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] protected SafeHandleMinusOneIsInvalid(bool ownsHandle) : base(new IntPtr(-1), ownsHandle) { } public override bool IsInvalid { get { return handle == new IntPtr(-1); } } } // Class of critical handle which uses 0 or -1 as an invalid handle. [SecurityPermission(SecurityAction.InheritanceDemand, UnmanagedCode=true)] [SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode=true)] public abstract class CriticalHandleZeroOrMinusOneIsInvalid : CriticalHandle { [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] protected CriticalHandleZeroOrMinusOneIsInvalid() : base(IntPtr.Zero) { } public override bool IsInvalid { get { return handle.IsNull() || handle == new IntPtr(-1); } } } // Class of critical handle which uses only -1 as an invalid handle. [SecurityPermission(SecurityAction.InheritanceDemand, UnmanagedCode=true)] [SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode=true)] public abstract class CriticalHandleMinusOneIsInvalid : CriticalHandle { [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] protected CriticalHandleMinusOneIsInvalid() : base(new IntPtr(-1)) { } public override bool IsInvalid { get { return handle == new IntPtr(-1); } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- IPAddress.cs
- DbSetClause.cs
- GridViewCellAutomationPeer.cs
- followingsibling.cs
- ChannelParameterCollection.cs
- BCLDebug.cs
- NamespaceCollection.cs
- DefaultBindingPropertyAttribute.cs
- PersonalizableTypeEntry.cs
- NativeCppClassAttribute.cs
- CodeAccessPermission.cs
- IndexerNameAttribute.cs
- SlotInfo.cs
- OdbcConnectionOpen.cs
- BinaryFormatterSinks.cs
- MembershipUser.cs
- MsmqBindingFilter.cs
- StandardBindingReliableSessionElement.cs
- DateTimeUtil.cs
- AppearanceEditorPart.cs
- Grammar.cs
- RadialGradientBrush.cs
- _SslSessionsCache.cs
- WinEventTracker.cs
- ContextConfiguration.cs
- ProfilePropertySettings.cs
- XmlDigitalSignatureProcessor.cs
- MeshGeometry3D.cs
- ParameterRetriever.cs
- FileNotFoundException.cs
- TcpConnectionPoolSettingsElement.cs
- SpeechDetectedEventArgs.cs
- IndexOutOfRangeException.cs
- DomainConstraint.cs
- EndPoint.cs
- ColorTransformHelper.cs
- DownloadProgressEventArgs.cs
- Timeline.cs
- DetailsViewRow.cs
- DataTableNewRowEvent.cs
- WebPartConnectionCollection.cs
- BinaryObjectInfo.cs
- StorageEntitySetMapping.cs
- UnsafeNativeMethods.cs
- PinnedBufferMemoryStream.cs
- CodeDOMUtility.cs
- _LocalDataStore.cs
- TraceListener.cs
- TraceSection.cs
- StylusButton.cs
- LambdaCompiler.Address.cs
- basenumberconverter.cs
- VersionPair.cs
- SafeNativeMethods.cs
- WindowsStreamSecurityBindingElement.cs
- ToolStripRenderEventArgs.cs
- ProcessActivityTreeOptions.cs
- ScrollBar.cs
- VolatileEnlistmentState.cs
- ContentHostHelper.cs
- TemplateXamlParser.cs
- XamlStyleSerializer.cs
- AdapterDictionary.cs
- ServiceNotStartedException.cs
- WorkflowNamespace.cs
- IISMapPath.cs
- NativeMethods.cs
- WebHttpBinding.cs
- FontUnitConverter.cs
- MailAddress.cs
- UnsafeNativeMethods.cs
- XappLauncher.cs
- RSACryptoServiceProvider.cs
- SourceFilter.cs
- ExpandSegment.cs
- SortExpressionBuilder.cs
- CannotUnloadAppDomainException.cs
- StructuredType.cs
- NestedContainer.cs
- ListDictionary.cs
- WebBrowserSiteBase.cs
- WebPartVerb.cs
- VSWCFServiceContractGenerator.cs
- PropertyGridCommands.cs
- XmlAnyElementAttributes.cs
- GraphicsContainer.cs
- CollectionMarkupSerializer.cs
- MenuBase.cs
- DragStartedEventArgs.cs
- TdsParser.cs
- HttpContextBase.cs
- RowToParametersTransformer.cs
- StylusButtonEventArgs.cs
- SqlUtil.cs
- PeerToPeerException.cs
- HttpRequestWrapper.cs
- GridPattern.cs
- TrackingProfileCache.cs
- WebPartDisplayModeCollection.cs
- recordstatefactory.cs