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
- TextServicesContext.cs
- AlternationConverter.cs
- TextTreePropertyUndoUnit.cs
- StringValueSerializer.cs
- XmlDataLoader.cs
- StorageRoot.cs
- Figure.cs
- PlatformNotSupportedException.cs
- BindingBase.cs
- XmlDataFileEditor.cs
- InheritedPropertyChangedEventArgs.cs
- TrustManagerMoreInformation.cs
- TemplateBindingExpressionConverter.cs
- Convert.cs
- FormViewPageEventArgs.cs
- VisualBasicSettingsHandler.cs
- LineVisual.cs
- DbParameterCollectionHelper.cs
- Region.cs
- SettingsPropertyValueCollection.cs
- CharAnimationUsingKeyFrames.cs
- OperationDescriptionCollection.cs
- BuildProviderCollection.cs
- TraceContextRecord.cs
- OracleNumber.cs
- LineProperties.cs
- DynamicUpdateCommand.cs
- InternalBufferOverflowException.cs
- UInt64.cs
- WorkflowCreationContext.cs
- PopupRoot.cs
- SystemException.cs
- DATA_BLOB.cs
- RectAnimation.cs
- AutomationProperties.cs
- DecoderFallback.cs
- Confirm.cs
- XhtmlBasicControlAdapter.cs
- CompensationTokenData.cs
- EnumBuilder.cs
- NativeMethods.cs
- SerializationInfo.cs
- HttpCachePolicy.cs
- OlePropertyStructs.cs
- ProcessHostConfigUtils.cs
- RepeaterItemCollection.cs
- ClrPerspective.cs
- Metafile.cs
- WindowsListViewItemStartMenu.cs
- DrawingServices.cs
- SystemIcmpV4Statistics.cs
- SamlConditions.cs
- HttpRequestTraceRecord.cs
- UnsafeNativeMethods.cs
- PathSegment.cs
- RowType.cs
- CultureInfoConverter.cs
- ButtonChrome.cs
- DefaultBinder.cs
- ObjectDataSourceChooseTypePanel.cs
- SqlCommandSet.cs
- MetabaseSettings.cs
- PageParser.cs
- VirtualPath.cs
- ReachSerializerAsync.cs
- TextTrailingCharacterEllipsis.cs
- ImagingCache.cs
- EditorZone.cs
- HighlightVisual.cs
- SystemUnicastIPAddressInformation.cs
- XmlConverter.cs
- IArgumentProvider.cs
- Unit.cs
- HijriCalendar.cs
- BlurEffect.cs
- SQLDouble.cs
- Lease.cs
- ModelFunctionTypeElement.cs
- DelegateArgument.cs
- FragmentQueryKB.cs
- URLString.cs
- ElementHostAutomationPeer.cs
- RecordConverter.cs
- Profiler.cs
- TableAutomationPeer.cs
- PtsHelper.cs
- SecurityElement.cs
- WebPartManagerInternals.cs
- OperationCanceledException.cs
- BevelBitmapEffect.cs
- FontInfo.cs
- mongolianshape.cs
- ConditionCollection.cs
- SmtpDigestAuthenticationModule.cs
- XmlSchemaComplexContentRestriction.cs
- WorkflowQueueInfo.cs
- TextStore.cs
- MouseEventArgs.cs
- PerformanceCounterScope.cs
- XmlResolver.cs