Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / 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
- XPathBinder.cs
- TypeSystem.cs
- Color.cs
- ConfigXmlElement.cs
- XmlBaseWriter.cs
- DuplexClientBase.cs
- PagePropertiesChangingEventArgs.cs
- WebBrowser.cs
- DynamicRendererThreadManager.cs
- References.cs
- NativeMethods.cs
- updateconfighost.cs
- WmlFormAdapter.cs
- SchemaTableColumn.cs
- TextServicesPropertyRanges.cs
- Stacktrace.cs
- ToolStripContentPanel.cs
- EventHandlerList.cs
- OdbcFactory.cs
- Model3DGroup.cs
- WorkflowEventArgs.cs
- UrlPath.cs
- DataKeyPropertyAttribute.cs
- TreeNodeClickEventArgs.cs
- PolicyImporterElementCollection.cs
- ProviderCommandInfoUtils.cs
- ClrProviderManifest.cs
- ComponentCollection.cs
- GACIdentityPermission.cs
- ValidationHelper.cs
- COM2ExtendedUITypeEditor.cs
- UrlPath.cs
- HMACRIPEMD160.cs
- autovalidator.cs
- EventMappingSettings.cs
- UpdateExpressionVisitor.cs
- FileLogRecordStream.cs
- UTF32Encoding.cs
- ParserOptions.cs
- DecimalFormatter.cs
- QueryableFilterRepeater.cs
- DrawingImage.cs
- MembershipUser.cs
- IdentitySection.cs
- DecimalAnimationUsingKeyFrames.cs
- XmlSchemaSimpleContentRestriction.cs
- BamlLocalizabilityResolver.cs
- Track.cs
- SerializationStore.cs
- MaterialGroup.cs
- Preprocessor.cs
- WebPartDescription.cs
- uribuilder.cs
- MouseGesture.cs
- CanonicalXml.cs
- RegionIterator.cs
- XmlBindingWorker.cs
- WindowPatternIdentifiers.cs
- StringReader.cs
- WebProxyScriptElement.cs
- BulletChrome.cs
- BigInt.cs
- DataGridViewAutoSizeModeEventArgs.cs
- BulletedList.cs
- DataGridViewTopRowAccessibleObject.cs
- CapabilitiesRule.cs
- XmlNamespaceDeclarationsAttribute.cs
- ElementNotEnabledException.cs
- TreeNodeConverter.cs
- StickyNote.cs
- MessageHeaders.cs
- HashCodeCombiner.cs
- ParseElement.cs
- ClientSideQueueItem.cs
- PackageProperties.cs
- TransformerInfo.cs
- ConnectionInterfaceCollection.cs
- SmiContext.cs
- SchemaRegistration.cs
- ConfigurationPropertyAttribute.cs
- XmlAnyElementAttributes.cs
- ToolBarPanel.cs
- RMPublishingDialog.cs
- SecurityException.cs
- ContextMarshalException.cs
- ViewSimplifier.cs
- HierarchicalDataBoundControl.cs
- RuleElement.cs
- TextBreakpoint.cs
- IntegrationExceptionEventArgs.cs
- IgnorePropertiesAttribute.cs
- EndPoint.cs
- processwaithandle.cs
- CacheHelper.cs
- DateTimeFormatInfo.cs
- BamlLocalizableResourceKey.cs
- PathSegmentCollection.cs
- _AcceptOverlappedAsyncResult.cs
- LinqToSqlWrapper.cs
- PageThemeBuildProvider.cs