Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Configuration / Microsoft / Win32 / SafeNativeMemoryHandle.cs / 1305376 / 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ZipIOCentralDirectoryFileHeader.cs
- EpmTargetTree.cs
- EndpointDiscoveryMetadata11.cs
- MsmqMessageProperty.cs
- WebPartVerbCollection.cs
- XmlWriterSettings.cs
- oledbconnectionstring.cs
- ResourceLoader.cs
- ProfileServiceManager.cs
- SiteMapProvider.cs
- SiteMapNodeItemEventArgs.cs
- ToolboxItemCollection.cs
- AdRotator.cs
- Range.cs
- CompiledQuery.cs
- SHA256CryptoServiceProvider.cs
- AllMembershipCondition.cs
- TypeDelegator.cs
- Calendar.cs
- InputProcessorProfilesLoader.cs
- ComplexBindingPropertiesAttribute.cs
- ControlBuilder.cs
- SqlConnectionStringBuilder.cs
- RelationshipManager.cs
- ExpressionBuilderCollection.cs
- UseManagedPresentationBindingElementImporter.cs
- PeerNearMe.cs
- SymbolTable.cs
- ListViewSelectEventArgs.cs
- TableLayoutSettings.cs
- RawContentTypeMapper.cs
- SqlNotificationRequest.cs
- DispatcherOperation.cs
- TextElementCollection.cs
- RepeatButtonAutomationPeer.cs
- OptimalTextSource.cs
- IISMapPath.cs
- MetadataItemCollectionFactory.cs
- CalculatedColumn.cs
- Assembly.cs
- JavaScriptSerializer.cs
- Shared.cs
- DbConnectionInternal.cs
- MultipartContentParser.cs
- SelectionListDesigner.cs
- Comparer.cs
- DropAnimation.xaml.cs
- BlurEffect.cs
- CallContext.cs
- TypeResolver.cs
- TemplateEditingFrame.cs
- Point.cs
- PolyBezierSegment.cs
- HttpWebRequest.cs
- SqlDelegatedTransaction.cs
- BooleanConverter.cs
- BamlRecordWriter.cs
- EmptyControlCollection.cs
- Misc.cs
- XmlSerializerVersionAttribute.cs
- MobileUITypeEditor.cs
- TagPrefixCollection.cs
- LineInfo.cs
- BinHexEncoding.cs
- ISO2022Encoding.cs
- ConsoleKeyInfo.cs
- DotExpr.cs
- DATA_BLOB.cs
- ToolStripButton.cs
- MachineKey.cs
- DesignerSerializerAttribute.cs
- DataGridToolTip.cs
- EntityParameter.cs
- LocalizabilityAttribute.cs
- PropertyEmitterBase.cs
- SessionStateUtil.cs
- Visual3D.cs
- ConfigurationStrings.cs
- TraceListener.cs
- _BasicClient.cs
- Variable.cs
- BeginEvent.cs
- FontDialog.cs
- AssemblyCache.cs
- TraceLog.cs
- ListViewGroupItemCollection.cs
- RTLAwareMessageBox.cs
- KoreanLunisolarCalendar.cs
- IndexedEnumerable.cs
- DesignerAutoFormatCollection.cs
- FormConverter.cs
- SecureUICommand.cs
- ToolStripRendererSwitcher.cs
- LostFocusEventManager.cs
- PriorityItem.cs
- HwndSourceKeyboardInputSite.cs
- DbConnectionHelper.cs
- TraceUtility.cs
- Page.cs
- Separator.cs