Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / 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
- OLEDB_Enum.cs
- MasterPageParser.cs
- InputBinder.cs
- StructuredType.cs
- FlowDocument.cs
- XmlDocumentType.cs
- RoutedPropertyChangedEventArgs.cs
- MailDefinition.cs
- DataGridItemEventArgs.cs
- ObjectStateManager.cs
- StrokeSerializer.cs
- ListViewInsertedEventArgs.cs
- TcpTransportElement.cs
- HeaderCollection.cs
- ToolBar.cs
- ComponentEditorForm.cs
- TextRangeEditTables.cs
- DialogWindow.cs
- ConstructorNeedsTagAttribute.cs
- RegistryPermission.cs
- Wizard.cs
- ToolStripLabel.cs
- CharEnumerator.cs
- Stopwatch.cs
- Calendar.cs
- MultilineStringConverter.cs
- SafeUserTokenHandle.cs
- URIFormatException.cs
- BamlMapTable.cs
- AsyncOperationManager.cs
- StringExpressionSet.cs
- XPathMultyIterator.cs
- HtmlInputHidden.cs
- LightweightCodeGenerator.cs
- FixedDocument.cs
- DefaultMemberAttribute.cs
- InstanceDataCollectionCollection.cs
- FacetEnabledSchemaElement.cs
- TemplateField.cs
- ContainerSelectorBehavior.cs
- PageAsyncTask.cs
- PositiveTimeSpanValidatorAttribute.cs
- CipherData.cs
- PairComparer.cs
- DynamicField.cs
- UIPermission.cs
- SubclassTypeValidatorAttribute.cs
- ISAPIRuntime.cs
- XD.cs
- DES.cs
- TransportChannelListener.cs
- Vector3DCollection.cs
- Gdiplus.cs
- AdornerDecorator.cs
- Label.cs
- OpenFileDialog.cs
- HttpInputStream.cs
- ResolveCriteriaCD1.cs
- QueryPageSettingsEventArgs.cs
- DataGridViewColumnCollectionEditor.cs
- GridEntry.cs
- LinkedResource.cs
- RangeBase.cs
- BuilderElements.cs
- DashStyles.cs
- WebConfigurationManager.cs
- ReadOnlyTernaryTree.cs
- FileChangeNotifier.cs
- DataSourceCache.cs
- QueryHandler.cs
- RegexRunnerFactory.cs
- StaticDataManager.cs
- __Filters.cs
- WS2007HttpBinding.cs
- ReferentialConstraintRoleElement.cs
- BaseCollection.cs
- EntityFunctions.cs
- DataGridViewLinkCell.cs
- WebPartConnectionsEventArgs.cs
- TraceContextEventArgs.cs
- OutputCacheSection.cs
- DateTimeParse.cs
- CompareInfo.cs
- SelectionPatternIdentifiers.cs
- LinqDataSourceUpdateEventArgs.cs
- FixedSOMFixedBlock.cs
- ZipIOExtraFieldZip64Element.cs
- ControlUtil.cs
- GetIndexBinder.cs
- MessageQueueException.cs
- UInt64.cs
- ScopeElementCollection.cs
- XmlSchemaAnyAttribute.cs
- TextElementEnumerator.cs
- Privilege.cs
- XmlCharCheckingReader.cs
- EntityDataSourceWizardForm.cs
- ColorMatrix.cs
- SmtpAuthenticationManager.cs
- AlgoModule.cs