Code:
/ FXUpdate3074 / FXUpdate3074 / 1.1 / untmp / whidbey / QFE / ndp / clr / src / BCL / Microsoft / Win32 / SafeHandles / Win32SafeHandles.cs / 2 / 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 [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 [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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- PageRouteHandler.cs
- DoubleKeyFrameCollection.cs
- DataGridDesigner.cs
- ApplicationGesture.cs
- SafeHandles.cs
- IOThreadScheduler.cs
- Logging.cs
- DesignerUtility.cs
- XPathNodeIterator.cs
- HttpPostedFile.cs
- DeviceContext2.cs
- DataGridViewUtilities.cs
- ColumnTypeConverter.cs
- WindowsUserNameSecurityTokenAuthenticator.cs
- PersonalizationState.cs
- Int32.cs
- ProgressBarHighlightConverter.cs
- BlockUIContainer.cs
- Exceptions.cs
- NameValueCollection.cs
- PersianCalendar.cs
- SByteStorage.cs
- TdsValueSetter.cs
- ToolStripButton.cs
- CommandPlan.cs
- URLIdentityPermission.cs
- TypeElementCollection.cs
- RowParagraph.cs
- PointConverter.cs
- ErrorFormatterPage.cs
- SpellerInterop.cs
- XmlText.cs
- CancellationState.cs
- MiniAssembly.cs
- MessageDescription.cs
- TextLine.cs
- RuntimeArgumentHandle.cs
- GlyphInfoList.cs
- RSAProtectedConfigurationProvider.cs
- WebPartTransformer.cs
- CompositionTarget.cs
- MenuItemStyleCollection.cs
- XmlStringTable.cs
- WebPartRestoreVerb.cs
- Brush.cs
- PersonalizationStateInfo.cs
- StrokeNodeData.cs
- SystemInfo.cs
- EntityDataSourceWrapper.cs
- UIElementHelper.cs
- HeaderElement.cs
- InternalControlCollection.cs
- TimelineGroup.cs
- StateChangeEvent.cs
- EntityDesignerDataSourceView.cs
- XPathAxisIterator.cs
- TextServicesManager.cs
- BinaryCommonClasses.cs
- ListViewInsertedEventArgs.cs
- TransportOutputChannel.cs
- EntityDataSourceWrapper.cs
- Choices.cs
- DownloadProgressEventArgs.cs
- ChannelManager.cs
- CompiledIdentityConstraint.cs
- DiscoveryDocumentSerializer.cs
- DictionaryGlobals.cs
- CachedRequestParams.cs
- QilTargetType.cs
- WindowsFont.cs
- RenderCapability.cs
- BindingContext.cs
- BrowserCapabilitiesFactoryBase.cs
- ListControl.cs
- ResourceCodeDomSerializer.cs
- DragEventArgs.cs
- StrokeCollectionDefaultValueFactory.cs
- SecurityRuntime.cs
- DetailsViewInsertEventArgs.cs
- QuaternionRotation3D.cs
- ComponentConverter.cs
- RtfControls.cs
- Scheduling.cs
- ToggleButton.cs
- DataGridViewIntLinkedList.cs
- SafeCoTaskMem.cs
- PenThreadWorker.cs
- CacheSection.cs
- TemplateComponentConnector.cs
- CRYPTPROTECT_PROMPTSTRUCT.cs
- CompiledELinqQueryState.cs
- HtmlInputReset.cs
- TypeForwardedToAttribute.cs
- XXXInfos.cs
- IConvertible.cs
- ConfigXmlWhitespace.cs
- DetailsViewUpdateEventArgs.cs
- XslTransform.cs
- TableLayoutColumnStyleCollection.cs
- InvalidCommandTreeException.cs