Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WCF / infocard / Client / System / IdentityModel / Selectors / SafeLibraryHandle.cs / 1305376 / SafeLibraryHandle.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.IdentityModel.Selectors { using System; using System.IO; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.Runtime.InteropServices; using System.Runtime.ConstrainedExecution; using System.Runtime.CompilerServices; using Microsoft.InfoCards.Diagnostics; using Microsoft.Win32; using System.Security.Permissions; using Microsoft.Win32.SafeHandles; // // Summary: // A class to wrap a library handle for reliability. // When LoadLibrary returns, the runtime stores the resulting IntPtr // into the already created SafeLibraryHandle. The runtime guarantees that // this operation is atomic, meaning that if the P/Invoke method successfully returns, // the IntPtr will be stored safely inside the SafeHandle. Once inside the SafeHandle, // even if an asynchronous exception occurs and prevents LoadLibrary's SafeLibraryHandle return // value from being stored, the relevant IntPtr is already stored within a managed object // whose critical finalizer will ensure its proper release. // [ SecurityPermission( SecurityAction.LinkDemand, UnmanagedCode=true ) ] class SafeLibraryHandle : SafeHandleZeroOrMinusOneIsInvalid { private SafeLibraryHandle() : base( true ) { } protected override bool ReleaseHandle() { #pragma warning suppress 56523 return FreeLibrary( handle ); } [DllImport( "kernel32.dll", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true, CallingConvention = CallingConvention.StdCall )] internal static extern SafeLibraryHandle LoadLibraryW( [MarshalAs( UnmanagedType.LPWStr )] string dllname ); [DllImport( "kernel32.dll", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true, CallingConvention = CallingConvention.StdCall )] internal static extern bool FreeLibrary( IntPtr hModule ); } } // 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
- ConsoleTraceListener.cs
- DeviceFiltersSection.cs
- ContainerParaClient.cs
- Int32EqualityComparer.cs
- MsmqTransportSecurity.cs
- ObjectPersistData.cs
- Bits.cs
- DriveInfo.cs
- InputBindingCollection.cs
- ClipboardData.cs
- IdentifierService.cs
- Fonts.cs
- SqlDataAdapter.cs
- TextBox.cs
- path.cs
- GeneralTransform3DGroup.cs
- TraversalRequest.cs
- Point3D.cs
- IOException.cs
- Content.cs
- StringValidatorAttribute.cs
- ErrorItem.cs
- TypeValidationEventArgs.cs
- ContentPlaceHolder.cs
- HttpTransportSecurity.cs
- BitmapInitialize.cs
- FormsIdentity.cs
- MarshalByValueComponent.cs
- MarshalDirectiveException.cs
- WhitespaceRuleLookup.cs
- ContentDisposition.cs
- ColorContextHelper.cs
- PopupControlService.cs
- LinkConverter.cs
- FunctionDetailsReader.cs
- PolicyImporterElementCollection.cs
- CustomErrorCollection.cs
- DesignRelation.cs
- ValidationError.cs
- documentsequencetextview.cs
- TemplateXamlTreeBuilder.cs
- DateTimeFormat.cs
- StructuralObject.cs
- ReceiveCompletedEventArgs.cs
- ImportOptions.cs
- Connection.cs
- AdapterUtil.cs
- SqlComparer.cs
- GatewayIPAddressInformationCollection.cs
- ChangeDirector.cs
- Section.cs
- InternalBufferOverflowException.cs
- DocumentViewerAutomationPeer.cs
- ClientSponsor.cs
- HtmlImage.cs
- QilReference.cs
- MethodSet.cs
- PartitionedStream.cs
- TimeSpanSecondsOrInfiniteConverter.cs
- ContentElementCollection.cs
- Splitter.cs
- ColorIndependentAnimationStorage.cs
- ButtonColumn.cs
- PrintPreviewDialog.cs
- ProviderSettingsCollection.cs
- HotCommands.cs
- Mapping.cs
- MouseButtonEventArgs.cs
- MenuRendererClassic.cs
- BitmapDownload.cs
- figurelength.cs
- ScrollChrome.cs
- HttpWebRequest.cs
- __Error.cs
- DbConnectionFactory.cs
- MemberRelationshipService.cs
- DBDataPermission.cs
- BamlLocalizableResourceKey.cs
- UnicastIPAddressInformationCollection.cs
- HttpChannelListener.cs
- EmptyEnumerable.cs
- AspNetHostingPermission.cs
- serverconfig.cs
- BufferBuilder.cs
- FixedSOMPageConstructor.cs
- DefinitionBase.cs
- Registry.cs
- XamlTypeMapper.cs
- TakeQueryOptionExpression.cs
- BooleanAnimationUsingKeyFrames.cs
- GreenMethods.cs
- BitmapEffectOutputConnector.cs
- FilterElement.cs
- UIAgentMonitorHandle.cs
- WindowsFormsDesignerOptionService.cs
- _CommandStream.cs
- DataGridViewTextBoxColumn.cs
- ConfigurationPropertyAttribute.cs
- _Connection.cs
- BuildProviderCollection.cs