Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / 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
- XmlTypeMapping.cs
- TraceRecord.cs
- PropertyNames.cs
- DurationConverter.cs
- InternalCache.cs
- MemberPath.cs
- UrlAuthFailureHandler.cs
- ExcCanonicalXml.cs
- ContentPosition.cs
- objectquery_tresulttype.cs
- SetMemberBinder.cs
- BindUriHelper.cs
- EdmFunctionAttribute.cs
- Graphics.cs
- DataBindingValueUIHandler.cs
- Funcletizer.cs
- ClientReliableChannelBinder.cs
- GenericTextProperties.cs
- EdmItemCollection.OcAssemblyCache.cs
- StatusStrip.cs
- BypassElementCollection.cs
- PlacementWorkspace.cs
- CharacterBufferReference.cs
- RemoteCryptoDecryptRequest.cs
- ToolBarButtonClickEvent.cs
- XsdBuildProvider.cs
- SHA256Managed.cs
- Primitive.cs
- SimpleHandlerFactory.cs
- TableRowGroup.cs
- DependencyObjectType.cs
- AuthenticationModuleElementCollection.cs
- XmlILAnnotation.cs
- SystemIPInterfaceStatistics.cs
- CookieProtection.cs
- ToolStripStatusLabel.cs
- SpeechUI.cs
- RedirectionProxy.cs
- OdbcError.cs
- DodSequenceMerge.cs
- Pkcs9Attribute.cs
- SizeAnimationUsingKeyFrames.cs
- CodeNamespaceImport.cs
- Bidi.cs
- FakeModelItemImpl.cs
- ReachDocumentReferenceSerializerAsync.cs
- ObjectItemAssemblyLoader.cs
- OracleInfoMessageEventArgs.cs
- InteropAutomationProvider.cs
- CompositionDesigner.cs
- LocalBuilder.cs
- ManagementDateTime.cs
- SignatureToken.cs
- ClientSettings.cs
- XmlAttribute.cs
- PropertyPathWorker.cs
- ToolStripDropDown.cs
- RegexCode.cs
- RequiredFieldValidator.cs
- ListView.cs
- AssociationTypeEmitter.cs
- MenuAdapter.cs
- DisposableCollectionWrapper.cs
- XmlStringTable.cs
- EntityConnection.cs
- BehaviorDragDropEventArgs.cs
- FontWeightConverter.cs
- XmlSchemaFacet.cs
- MemberCollection.cs
- XmlSchema.cs
- MsmqDiagnostics.cs
- IIS7UserPrincipal.cs
- DataSourceSelectArguments.cs
- ApplicationServicesHostFactory.cs
- CryptoKeySecurity.cs
- CommonXSendMessage.cs
- ClientConfigurationSystem.cs
- GregorianCalendar.cs
- FormClosingEvent.cs
- UpdatableWrapper.cs
- XomlCompilerResults.cs
- AutoScrollExpandMessageFilter.cs
- RadioButtonRenderer.cs
- OutputCacheModule.cs
- PropertyGrid.cs
- LabelLiteral.cs
- CommandManager.cs
- cache.cs
- MobileControlsSectionHandler.cs
- TypeBinaryExpression.cs
- ITextView.cs
- HtmlControl.cs
- DataSourceControlBuilder.cs
- ProgressBar.cs
- DateTimeUtil.cs
- QueryGeneratorBase.cs
- FragmentQuery.cs
- PageCatalogPartDesigner.cs
- _IPv6Address.cs
- TypeInfo.cs