Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / fx / src / Configuration / Microsoft / Win32 / SafeNativeMemoryHandle.cs / 1 / SafeNativeMemoryHandle.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace Microsoft.Win32 { using System.Runtime.InteropServices; using System; using System.Security.Permissions; using Microsoft.Win32.SafeHandles; using System.Configuration; // Safehandle for memory handles [System.Security.SuppressUnmanagedCodeSecurityAttribute()] internal sealed class SafeNativeMemoryHandle : SafeHandleZeroOrMinusOneIsInvalid { private bool _useLocalFree = false; [SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode = true)] internal SafeNativeMemoryHandle() : this(false) { } internal SafeNativeMemoryHandle(bool useLocalFree) : base(true) { _useLocalFree = useLocalFree; } [SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode = true)] internal SafeNativeMemoryHandle(IntPtr handle, bool ownsHandle) : base(ownsHandle) { SetHandle(handle); } internal void SetDataHandle(IntPtr handle) { SetHandle(handle); } override protected bool ReleaseHandle() { if (handle != IntPtr.Zero) { if (_useLocalFree == true) UnsafeNativeMethods.LocalFree(handle); else Marshal.FreeHGlobal(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. // //----------------------------------------------------------------------------- namespace Microsoft.Win32 { using System.Runtime.InteropServices; using System; using System.Security.Permissions; using Microsoft.Win32.SafeHandles; using System.Configuration; // Safehandle for memory handles [System.Security.SuppressUnmanagedCodeSecurityAttribute()] internal sealed class SafeNativeMemoryHandle : SafeHandleZeroOrMinusOneIsInvalid { private bool _useLocalFree = false; [SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode = true)] internal SafeNativeMemoryHandle() : this(false) { } internal SafeNativeMemoryHandle(bool useLocalFree) : base(true) { _useLocalFree = useLocalFree; } [SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode = true)] internal SafeNativeMemoryHandle(IntPtr handle, bool ownsHandle) : base(ownsHandle) { SetHandle(handle); } internal void SetDataHandle(IntPtr handle) { SetHandle(handle); } override protected bool ReleaseHandle() { if (handle != IntPtr.Zero) { if (_useLocalFree == true) UnsafeNativeMethods.LocalFree(handle); else Marshal.FreeHGlobal(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
- KeyGesture.cs
- RunInstallerAttribute.cs
- odbcmetadatacolumnnames.cs
- Bezier.cs
- GeneralTransform3DTo2D.cs
- WebPartMenuStyle.cs
- FormViewCommandEventArgs.cs
- newitemfactory.cs
- Convert.cs
- Contracts.cs
- WindowsSysHeader.cs
- EditorPart.cs
- BrowserDefinition.cs
- ConstraintStruct.cs
- ObjectParameterCollection.cs
- CallbackHandler.cs
- EdmMember.cs
- HitTestWithPointDrawingContextWalker.cs
- SelectionItemProviderWrapper.cs
- SecureStringHasher.cs
- HTMLTextWriter.cs
- HttpHeaderCollection.cs
- ZipIOCentralDirectoryBlock.cs
- FamilyMapCollection.cs
- EntityModelSchemaGenerator.cs
- SignatureDescription.cs
- GeneralTransform3DTo2DTo3D.cs
- LicenseContext.cs
- HuffmanTree.cs
- DbConnectionPoolGroupProviderInfo.cs
- EntityDataSourceWrapperCollection.cs
- MatrixConverter.cs
- DesignerVerb.cs
- QueryOperationResponseOfT.cs
- DataControlPagerLinkButton.cs
- Comparer.cs
- AnnotationComponentManager.cs
- RegionData.cs
- PeerContact.cs
- wmiprovider.cs
- HostingPreferredMapPath.cs
- SQLUtility.cs
- XmlImplementation.cs
- Wildcard.cs
- TileModeValidation.cs
- WmlPanelAdapter.cs
- RadialGradientBrush.cs
- oledbmetadatacolumnnames.cs
- HttpRuntime.cs
- DocumentAutomationPeer.cs
- GZipStream.cs
- HtmlContainerControl.cs
- SqlFileStream.cs
- StreamSecurityUpgradeInitiator.cs
- EncryptedPackage.cs
- StandardRuntimeEnumValidatorAttribute.cs
- ViewBox.cs
- X500Name.cs
- InputLanguageEventArgs.cs
- DataGridViewDataErrorEventArgs.cs
- JournalEntry.cs
- ColumnMap.cs
- ReflectionUtil.cs
- TripleDES.cs
- DataGridViewCellLinkedList.cs
- ParserContext.cs
- MulticastNotSupportedException.cs
- DelimitedListTraceListener.cs
- MenuCommands.cs
- KeyValueSerializer.cs
- ToolZone.cs
- MdiWindowListStrip.cs
- ZipIOCentralDirectoryDigitalSignature.cs
- PostBackOptions.cs
- DrawingAttributeSerializer.cs
- Int32Collection.cs
- SqlNotificationRequest.cs
- X509ThumbprintKeyIdentifierClause.cs
- WizardForm.cs
- BooleanKeyFrameCollection.cs
- SHA256Managed.cs
- ClientTargetCollection.cs
- TreeNodeStyle.cs
- HtmlControlPersistable.cs
- AttributeEmitter.cs
- SchemaTableColumn.cs
- AssemblySettingAttributes.cs
- DebuggerAttributes.cs
- ObjectHelper.cs
- SystemInformation.cs
- HandlerFactoryCache.cs
- EventBuilder.cs
- xmlformatgeneratorstatics.cs
- DocumentViewer.cs
- KeySpline.cs
- AttributeInfo.cs
- HttpApplicationFactory.cs
- WindowsPen.cs
- RuleSettings.cs
- ScalarType.cs