Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / 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;
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// ==++==
//
// 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;
}
}
}
// 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
- StylusShape.cs
- ListViewEditEventArgs.cs
- TagMapCollection.cs
- Random.cs
- HttpsHostedTransportConfiguration.cs
- PackageDigitalSignatureManager.cs
- HttpApplicationFactory.cs
- PropertyNames.cs
- CommandValueSerializer.cs
- X509UI.cs
- SqlNamer.cs
- _NativeSSPI.cs
- SequentialOutput.cs
- GiveFeedbackEvent.cs
- DbMetaDataColumnNames.cs
- ExternalDataExchangeService.cs
- CanonicalXml.cs
- IPAddressCollection.cs
- QueuePropertyVariants.cs
- CharAnimationBase.cs
- AssemblyBuilder.cs
- Blend.cs
- _AutoWebProxyScriptHelper.cs
- _ListenerAsyncResult.cs
- SessionStateItemCollection.cs
- HttpWebResponse.cs
- ProxySimple.cs
- BulletedListEventArgs.cs
- BaseResourcesBuildProvider.cs
- SqlDataReaderSmi.cs
- PenThreadPool.cs
- ParameterBuilder.cs
- _ListenerAsyncResult.cs
- BitmapEffectGroup.cs
- ResourceProviderFactory.cs
- IPipelineRuntime.cs
- DocumentApplicationJournalEntry.cs
- URLMembershipCondition.cs
- MSAAEventDispatcher.cs
- ExpressionEditorSheet.cs
- KeySplineConverter.cs
- ToolStripDropDown.cs
- WinFormsUtils.cs
- FocusChangedEventArgs.cs
- DocumentCollection.cs
- DefinitionUpdate.cs
- ClientSideProviderDescription.cs
- ipaddressinformationcollection.cs
- SchemaMapping.cs
- AuthenticationSection.cs
- ConfigXmlCDataSection.cs
- PrintingPermissionAttribute.cs
- ClientFormsAuthenticationCredentials.cs
- EUCJPEncoding.cs
- ProviderConnectionPointCollection.cs
- JoinSymbol.cs
- IOThreadTimer.cs
- DispatchOperation.cs
- SessionEndingEventArgs.cs
- DataObjectPastingEventArgs.cs
- FtpCachePolicyElement.cs
- LabelLiteral.cs
- QilInvokeEarlyBound.cs
- SocketPermission.cs
- SqlRowUpdatedEvent.cs
- NullPackagingPolicy.cs
- XamlSerializerUtil.cs
- Transform3DGroup.cs
- DataGridViewComboBoxColumn.cs
- AssemblyContextControlItem.cs
- CompilerGeneratedAttribute.cs
- StaticContext.cs
- _AutoWebProxyScriptHelper.cs
- JsonServiceDocumentSerializer.cs
- MimeParameter.cs
- Journal.cs
- SerializationHelper.cs
- TraceEventCache.cs
- UnsafeNativeMethods.cs
- ADMembershipProvider.cs
- RoutedEvent.cs
- ParameterRetriever.cs
- DbConnectionPoolGroup.cs
- ElementFactory.cs
- COM2ExtendedUITypeEditor.cs
- BackoffTimeoutHelper.cs
- Margins.cs
- ApplicationTrust.cs
- FormClosingEvent.cs
- StateDesigner.LayoutSelectionGlyph.cs
- Crc32.cs
- WindowsListViewGroup.cs
- RootBrowserWindowAutomationPeer.cs
- PeerObject.cs
- HorizontalAlignConverter.cs
- AbstractSvcMapFileLoader.cs
- OutputCacheProfileCollection.cs
- Addressing.cs
- ImageFormat.cs
- FunctionUpdateCommand.cs