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
- NeutralResourcesLanguageAttribute.cs
- XPathNavigatorReader.cs
- MemberPathMap.cs
- ObjectIDGenerator.cs
- UnsafeNativeMethodsTablet.cs
- BreadCrumbTextConverter.cs
- SuppressMessageAttribute.cs
- SqlDataSourceCache.cs
- wgx_sdk_version.cs
- TabletDeviceInfo.cs
- TextContainerChangeEventArgs.cs
- SqlTypesSchemaImporter.cs
- ActivityWithResult.cs
- ModuleConfigurationInfo.cs
- HtmlTextArea.cs
- PackageFilter.cs
- ConfigXmlText.cs
- WorkItem.cs
- BrowserTree.cs
- StringWriter.cs
- Int16KeyFrameCollection.cs
- TextBoxAutoCompleteSourceConverter.cs
- HtmlMeta.cs
- FormsAuthentication.cs
- CatalogPartChrome.cs
- ComponentDispatcher.cs
- Rotation3D.cs
- DataSourceView.cs
- CheckBoxRenderer.cs
- Random.cs
- RowParagraph.cs
- AccessControlEntry.cs
- TextPointerBase.cs
- FreeFormDesigner.cs
- SortableBindingList.cs
- KeyValueInternalCollection.cs
- LinkConverter.cs
- ListViewItemSelectionChangedEvent.cs
- ColorMap.cs
- HMACSHA512.cs
- DataGridPageChangedEventArgs.cs
- TypedCompletedAsyncResult.cs
- NativeMethods.cs
- XPathDocumentBuilder.cs
- PresentationTraceSources.cs
- IndexerNameAttribute.cs
- OracleCommandBuilder.cs
- PolicyStatement.cs
- SmiXetterAccessMap.cs
- ThumbButtonInfo.cs
- XPathNodeList.cs
- EffectiveValueEntry.cs
- XomlCompiler.cs
- XmlTypeAttribute.cs
- ConstructorBuilder.cs
- InvalidAsynchronousStateException.cs
- SQLUtility.cs
- PeerTransportBindingElement.cs
- XmlDomTextWriter.cs
- UnionCqlBlock.cs
- HandledMouseEvent.cs
- BinaryWriter.cs
- TraceRecord.cs
- ISessionStateStore.cs
- TTSVoice.cs
- MemberInitExpression.cs
- NavigationPropertyEmitter.cs
- ToolStripDropDown.cs
- XmlDocument.cs
- JobPageOrder.cs
- TargetException.cs
- RuleSettingsCollection.cs
- XPathExpr.cs
- OutputWindow.cs
- DataGridItemAttachedStorage.cs
- ControlUtil.cs
- ActivityCompletionCallbackWrapper.cs
- XPathPatternParser.cs
- FeatureManager.cs
- EntryPointNotFoundException.cs
- webbrowsersite.cs
- InkCanvasInnerCanvas.cs
- ArrayHelper.cs
- ConfigurationSectionHelper.cs
- HtmlInputSubmit.cs
- OperationGenerator.cs
- ChunkedMemoryStream.cs
- CipherData.cs
- CombinedGeometry.cs
- MemberPathMap.cs
- GridPattern.cs
- MailMessage.cs
- MenuItemBindingCollection.cs
- ColorMap.cs
- BreakRecordTable.cs
- SchemaLookupTable.cs
- FactoryGenerator.cs
- DesignerDataSchemaClass.cs
- InvokeMethodActivityDesigner.cs
- isolationinterop.cs