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
- ButtonFieldBase.cs
- BasicAsyncResult.cs
- TextBox.cs
- SignatureDescription.cs
- SizeConverter.cs
- BrowserCapabilitiesCompiler.cs
- DoubleAnimationBase.cs
- safex509handles.cs
- UnconditionalPolicy.cs
- ConversionValidationRule.cs
- AdRotatorDesigner.cs
- RowBinding.cs
- CachedRequestParams.cs
- EncryptedPackage.cs
- WebPartMovingEventArgs.cs
- PersonalizationAdministration.cs
- DrawListViewSubItemEventArgs.cs
- PropagatorResult.cs
- Matrix.cs
- TextEvent.cs
- SqlWebEventProvider.cs
- RoutedEventHandlerInfo.cs
- ClientType.cs
- TextRangeEditLists.cs
- EntityDataSourceEntitySetNameItem.cs
- MappingSource.cs
- FontNamesConverter.cs
- OleDbPermission.cs
- PageCodeDomTreeGenerator.cs
- ReferenceService.cs
- WebPartDisplayModeEventArgs.cs
- SignedInfo.cs
- RegexRunnerFactory.cs
- DocumentPropertiesDialog.cs
- TextCompositionEventArgs.cs
- DomainConstraint.cs
- FilterEventArgs.cs
- AdapterUtil.cs
- TextRangeEditLists.cs
- XmlSchemaAny.cs
- Underline.cs
- Rect3D.cs
- ContextProperty.cs
- MediaTimeline.cs
- FilteredDataSetHelper.cs
- XmlSchemaAnyAttribute.cs
- UnregisterInfo.cs
- ExpressionNode.cs
- StandardCommandToolStripMenuItem.cs
- DesignerAdRotatorAdapter.cs
- BoundField.cs
- CriticalFinalizerObject.cs
- SqlLiftWhereClauses.cs
- DataColumnSelectionConverter.cs
- AlgoModule.cs
- LayoutInformation.cs
- AnnotationComponentManager.cs
- TopClause.cs
- AnimationStorage.cs
- SafeBitVector32.cs
- ProfileManager.cs
- ControlBuilder.cs
- ScriptingProfileServiceSection.cs
- DesignerSerializerAttribute.cs
- PersistenceTypeAttribute.cs
- RectValueSerializer.cs
- XamlTemplateSerializer.cs
- ChannelFactory.cs
- OrderedDictionaryStateHelper.cs
- MailFileEditor.cs
- RSAPKCS1SignatureFormatter.cs
- ConfigXmlComment.cs
- DataRecordInternal.cs
- _TransmitFileOverlappedAsyncResult.cs
- AsyncResult.cs
- AnnotationMap.cs
- TableLayoutPanelCodeDomSerializer.cs
- JsonClassDataContract.cs
- SqlDataReader.cs
- COM2FontConverter.cs
- PassportAuthentication.cs
- ExpressionTable.cs
- EventData.cs
- X509Utils.cs
- SelectionService.cs
- ArrayWithOffset.cs
- DirectoryNotFoundException.cs
- ReversePositionQuery.cs
- TextFormattingConverter.cs
- ColumnWidthChangedEvent.cs
- MediaSystem.cs
- XmlSchemaDocumentation.cs
- TextReader.cs
- InstanceHandleReference.cs
- LocationSectionRecord.cs
- CommandCollectionEditor.cs
- RelationshipDetailsRow.cs
- CalendarDataBindingHandler.cs
- TextClipboardData.cs
- TextRangeEdit.cs