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
- AccessText.cs
- ActivityDesignerAccessibleObject.cs
- Win32.cs
- SqlUserDefinedTypeAttribute.cs
- LicenseManager.cs
- BufferModeSettings.cs
- GraphicsContext.cs
- Lookup.cs
- TextDecorationLocationValidation.cs
- DbModificationCommandTree.cs
- ContractCodeDomInfo.cs
- EventSource.cs
- UnsafeNativeMethodsPenimc.cs
- WaitHandle.cs
- SafeRightsManagementHandle.cs
- WindowsFont.cs
- ValidatorCollection.cs
- EmptyCollection.cs
- BindingValueChangedEventArgs.cs
- MemberProjectionIndex.cs
- DbInsertCommandTree.cs
- ThrowHelper.cs
- SortedList.cs
- ServiceOperation.cs
- ThreadPool.cs
- ArrayElementGridEntry.cs
- RegistrationServices.cs
- COM2Enum.cs
- Crypto.cs
- FloatSumAggregationOperator.cs
- Profiler.cs
- AmbientLight.cs
- DelegatedStream.cs
- NonClientArea.cs
- ProviderConnectionPointCollection.cs
- GetPageNumberCompletedEventArgs.cs
- LoadedOrUnloadedOperation.cs
- Decimal.cs
- ClientSideQueueItem.cs
- BidPrivateBase.cs
- OlePropertyStructs.cs
- PropertyChangedEventArgs.cs
- XmlCountingReader.cs
- Material.cs
- safePerfProviderHandle.cs
- DataGridColumnsPage.cs
- SamlAssertion.cs
- JsonFormatGeneratorStatics.cs
- PhoneCallDesigner.cs
- CodeSubDirectory.cs
- MetadataItemEmitter.cs
- SecureEnvironment.cs
- AssemblyBuilder.cs
- SimpleFieldTemplateUserControl.cs
- JsonUriDataContract.cs
- CompilationLock.cs
- TypographyProperties.cs
- DataQuery.cs
- TableSectionStyle.cs
- DataGridViewCellFormattingEventArgs.cs
- DateTimeFormatInfo.cs
- XmlHierarchyData.cs
- Int16.cs
- ParameterToken.cs
- EntityContainerAssociationSetEnd.cs
- ByteAnimationBase.cs
- MexNamedPipeBindingElement.cs
- RadioButtonPopupAdapter.cs
- CriticalHandle.cs
- PermissionAttributes.cs
- Lease.cs
- Zone.cs
- Encoder.cs
- SerializationEventsCache.cs
- DbProviderServices.cs
- AlphabeticalEnumConverter.cs
- BypassElementCollection.cs
- InArgument.cs
- MessageOperationFormatter.cs
- HttpClientCertificate.cs
- altserialization.cs
- DispatchWrapper.cs
- CssStyleCollection.cs
- SafeNativeMethods.cs
- ResourceDictionaryCollection.cs
- XmlEncoding.cs
- BinaryObjectInfo.cs
- InputLangChangeEvent.cs
- SqlMethodTransformer.cs
- MethodSet.cs
- TextParentUndoUnit.cs
- ErrorWrapper.cs
- TextMetrics.cs
- NativeMethodsCLR.cs
- CodeMemberProperty.cs
- RepeatInfo.cs
- ExternalFile.cs
- NamespaceExpr.cs
- XmlTextReader.cs
- ToolStripContextMenu.cs