Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / clr / src / BCL / Microsoft / Win32 / SafeHandles / SafeViewOfFileHandle.cs / 1 / SafeViewOfFileHandle.cs
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
/*============================================================
**
** Class: SafeViewOfFileHandle
**
**
** A wrapper for file handles
**
**
===========================================================*/
using System;
using System.Security;
using System.Security.Permissions;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using System.Runtime.ConstrainedExecution;
using System.Runtime.Versioning;
using Microsoft.Win32;
using Microsoft.Win32.SafeHandles;
namespace Microsoft.Win32.SafeHandles
{
internal sealed class SafeViewOfFileHandle : SafeHandleZeroOrMinusOneIsInvalid
{
[SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode=true)]
internal SafeViewOfFileHandle() : base(true) {}
// 0 is an Invalid Handle
[SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode=true)]
internal SafeViewOfFileHandle(IntPtr handle, bool ownsHandle) : base (ownsHandle) {
SetHandle(handle);
}
[ResourceExposure(ResourceScope.Machine)]
[ResourceConsumption(ResourceScope.Machine)]
override protected bool ReleaseHandle()
{
if (Win32Native.UnmapViewOfFile(handle))
{
handle = IntPtr.Zero;
return true;
}
return false;
}
}
}
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- IDispatchConstantAttribute.cs
- ToolStripDropTargetManager.cs
- DataRowCollection.cs
- DrawingServices.cs
- XmlSubtreeReader.cs
- IntSecurity.cs
- StylusPlugInCollection.cs
- ProxyGenerator.cs
- BindingExpressionBase.cs
- ConnectionPool.cs
- CollectionConverter.cs
- SelfIssuedAuthAsymmetricKey.cs
- DCSafeHandle.cs
- AsyncPostBackTrigger.cs
- DiscardableAttribute.cs
- NodeFunctions.cs
- SymbolEqualComparer.cs
- XhtmlBasicFormAdapter.cs
- xml.cs
- DetailsViewRowCollection.cs
- ControlEvent.cs
- BamlLocalizerErrorNotifyEventArgs.cs
- Renderer.cs
- UDPClient.cs
- SourceFileBuildProvider.cs
- RelatedView.cs
- PathFigureCollection.cs
- EventLog.cs
- Journaling.cs
- ObjectContext.cs
- AsyncInvokeContext.cs
- ProcessHostFactoryHelper.cs
- CaseInsensitiveOrdinalStringComparer.cs
- SQLInt32Storage.cs
- SyndicationSerializer.cs
- HostProtectionPermission.cs
- EncoderNLS.cs
- RichTextBoxDesigner.cs
- XPathDocumentIterator.cs
- Popup.cs
- WindowsFormsHelpers.cs
- _NativeSSPI.cs
- SQLMembershipProvider.cs
- CultureInfoConverter.cs
- CodeGotoStatement.cs
- UserControlAutomationPeer.cs
- AnyAllSearchOperator.cs
- WindowsAuthenticationEventArgs.cs
- ParentUndoUnit.cs
- ConfigXmlCDataSection.cs
- XPathException.cs
- TableRow.cs
- BinaryObjectWriter.cs
- MoveSizeWinEventHandler.cs
- SqlFunctions.cs
- DetailsViewCommandEventArgs.cs
- PrePrepareMethodAttribute.cs
- DefaultProxySection.cs
- SpotLight.cs
- DeferredSelectedIndexReference.cs
- TypeResolvingOptions.cs
- XPathBinder.cs
- ZoneButton.cs
- GeometryCombineModeValidation.cs
- BaseProcessor.cs
- TreeView.cs
- MeshGeometry3D.cs
- ColumnMapVisitor.cs
- OperationResponse.cs
- SHA1Managed.cs
- ParserHooks.cs
- DataColumnMappingCollection.cs
- CharEntityEncoderFallback.cs
- BindingMemberInfo.cs
- PropertyInformationCollection.cs
- RequestStatusBarUpdateEventArgs.cs
- CqlLexerHelpers.cs
- HyperLink.cs
- ResXDataNode.cs
- AssertSection.cs
- ClientCultureInfo.cs
- sqlstateclientmanager.cs
- DownloadProgressEventArgs.cs
- CompiledQuery.cs
- StrokeNodeOperations.cs
- FtpCachePolicyElement.cs
- PeerResolverBindingElement.cs
- shaperfactoryquerycacheentry.cs
- StatusBarDrawItemEvent.cs
- VideoDrawing.cs
- NullExtension.cs
- XmlHierarchicalEnumerable.cs
- MetadataItem.cs
- OperationAbortedException.cs
- ImageIndexConverter.cs
- PropagatorResult.cs
- OnOperation.cs
- TableColumnCollectionInternal.cs
- DataColumnCollection.cs
- OutputCacheSection.cs