Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / ndp / fx / src / CompMod / Microsoft / Win32 / SafeHandles / SafeLibraryHandle.cs / 1 / SafeLibraryHandle.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== /*============================================================ ** ** Class: SafeLibraryHandle ** **Author: David Gutierrez ([....]) ** ** A wrapper for a library handles ** ** Date: July 8, 2002 ** ===========================================================*/ using System; using System.Security; using System.Security.Permissions; using System.Runtime.InteropServices; using System.Runtime.CompilerServices; using Microsoft.Win32; using Microsoft.Win32.SafeHandles; using System.Runtime.ConstrainedExecution; namespace Microsoft.Win32.SafeHandles { [HostProtectionAttribute(MayLeakOnAbort = true)] [SuppressUnmanagedCodeSecurityAttribute] internal sealed class SafeLibraryHandle : SafeHandleZeroOrMinusOneIsInvalid { // Note that LoadLibraryEx returns 0 on failure internal SafeLibraryHandle() : base(true) {} [DllImport(ExternDll.Kernel32, CharSet=System.Runtime.InteropServices.CharSet.Unicode, SetLastError=true)] internal static extern SafeLibraryHandle LoadLibraryEx(string libFilename, IntPtr reserved, int flags); [DllImport(ExternDll.Kernel32, CharSet=System.Runtime.InteropServices.CharSet.Unicode)] [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] private static extern bool FreeLibrary(IntPtr hModule); override protected bool ReleaseHandle() { return FreeLibrary(handle); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== /*============================================================ ** ** Class: SafeLibraryHandle ** **Author: David Gutierrez ([....]) ** ** A wrapper for a library handles ** ** Date: July 8, 2002 ** ===========================================================*/ using System; using System.Security; using System.Security.Permissions; using System.Runtime.InteropServices; using System.Runtime.CompilerServices; using Microsoft.Win32; using Microsoft.Win32.SafeHandles; using System.Runtime.ConstrainedExecution; namespace Microsoft.Win32.SafeHandles { [HostProtectionAttribute(MayLeakOnAbort = true)] [SuppressUnmanagedCodeSecurityAttribute] internal sealed class SafeLibraryHandle : SafeHandleZeroOrMinusOneIsInvalid { // Note that LoadLibraryEx returns 0 on failure internal SafeLibraryHandle() : base(true) {} [DllImport(ExternDll.Kernel32, CharSet=System.Runtime.InteropServices.CharSet.Unicode, SetLastError=true)] internal static extern SafeLibraryHandle LoadLibraryEx(string libFilename, IntPtr reserved, int flags); [DllImport(ExternDll.Kernel32, CharSet=System.Runtime.InteropServices.CharSet.Unicode)] [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] private static extern bool FreeLibrary(IntPtr hModule); override protected bool ReleaseHandle() { return FreeLibrary(handle); } } } // 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
- RegexTree.cs
- ValueTable.cs
- WebControl.cs
- ResourcePool.cs
- TemplateContainer.cs
- FixedPage.cs
- XmlQueryType.cs
- RangeValuePatternIdentifiers.cs
- DisplayNameAttribute.cs
- UnionCodeGroup.cs
- ManagedWndProcTracker.cs
- GridViewColumnCollectionChangedEventArgs.cs
- LinqDataSourceDisposeEventArgs.cs
- OracleColumn.cs
- MailAddressCollection.cs
- bindurihelper.cs
- _NestedMultipleAsyncResult.cs
- ContextMenu.cs
- ColorConvertedBitmap.cs
- UrlMapping.cs
- DynamicControlParameter.cs
- SystemPens.cs
- PropertyChangedEventManager.cs
- DecodeHelper.cs
- KeyInterop.cs
- SchemaEntity.cs
- GridItemProviderWrapper.cs
- XPathDocumentBuilder.cs
- DateTime.cs
- OrderedParallelQuery.cs
- FormsAuthenticationUserCollection.cs
- DynamicExpression.cs
- TimeEnumHelper.cs
- ConnectivityStatus.cs
- Codec.cs
- XNameConverter.cs
- Literal.cs
- ServicePointManager.cs
- UIElementPropertyUndoUnit.cs
- GridViewDeleteEventArgs.cs
- WindowsTokenRoleProvider.cs
- StreamGeometryContext.cs
- ReadingWritingEntityEventArgs.cs
- Focus.cs
- FormClosingEvent.cs
- AnnotationService.cs
- ModelItemDictionary.cs
- EDesignUtil.cs
- GenericRootAutomationPeer.cs
- RTLAwareMessageBox.cs
- ValueSerializer.cs
- ImageFormatConverter.cs
- GeneralTransform3D.cs
- WindowsTitleBar.cs
- Cursors.cs
- CanExecuteRoutedEventArgs.cs
- TypeInitializationException.cs
- ClientFormsAuthenticationMembershipProvider.cs
- SqlDataSource.cs
- DataMisalignedException.cs
- PropertyReferenceExtension.cs
- ScrollItemProviderWrapper.cs
- HttpListenerException.cs
- StyleCollection.cs
- UnsafeNativeMethods.cs
- MessageQueuePermissionEntryCollection.cs
- WCFBuildProvider.cs
- TemplateBindingExpression.cs
- OletxTransactionManager.cs
- XpsResource.cs
- WsatServiceCertificate.cs
- ContentTypeSettingClientMessageFormatter.cs
- NamespaceInfo.cs
- CustomGrammar.cs
- DesigntimeLicenseContextSerializer.cs
- WindowsGraphics2.cs
- OpenFileDialog.cs
- XmlQuerySequence.cs
- RadioButtonBaseAdapter.cs
- GiveFeedbackEvent.cs
- SerializableAttribute.cs
- SectionUpdates.cs
- ClientSettings.cs
- ProfilePropertyNameValidator.cs
- Misc.cs
- InstancePersistence.cs
- COM2ColorConverter.cs
- ArrayWithOffset.cs
- RelatedCurrencyManager.cs
- PerformanceCounter.cs
- EntryIndex.cs
- AstTree.cs
- Inflater.cs
- BindingCollection.cs
- ImageCodecInfoPrivate.cs
- PropertyItemInternal.cs
- UpdatePanelTriggerCollection.cs
- TransportDefaults.cs
- FontStyles.cs
- ImportOptions.cs