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
- ZipIOFileItemStream.cs
- ToolZone.cs
- BatchParser.cs
- wgx_exports.cs
- PTConverter.cs
- ObjectItemCachedAssemblyLoader.cs
- Expression.cs
- ConfigurationElementProperty.cs
- ThreadInterruptedException.cs
- DataServiceHost.cs
- ScrollContentPresenter.cs
- ToolStripPanelRenderEventArgs.cs
- XpsTokenContext.cs
- WebBrowserNavigatingEventHandler.cs
- SourceSwitch.cs
- SubstitutionDesigner.cs
- ellipse.cs
- StylusCaptureWithinProperty.cs
- VectorAnimationUsingKeyFrames.cs
- XmlSchemaGroup.cs
- ReaderContextStackData.cs
- AttributeAction.cs
- XmlCustomFormatter.cs
- XmlTextReaderImplHelpers.cs
- ExtensionQuery.cs
- IndexedString.cs
- XmlSchemaSimpleContentRestriction.cs
- DrawingImage.cs
- ValidationError.cs
- entityreference_tresulttype.cs
- EventData.cs
- ArrayList.cs
- ProjectionCamera.cs
- RelationshipEndCollection.cs
- WhiteSpaceTrimStringConverter.cs
- WebPartCloseVerb.cs
- WebPartConnection.cs
- FileDataSourceCache.cs
- ListenerServiceInstallComponent.cs
- EffectiveValueEntry.cs
- ModuleConfigurationInfo.cs
- BindToObject.cs
- CodeNamespaceImportCollection.cs
- HealthMonitoringSection.cs
- PasswordDeriveBytes.cs
- SoapReflectionImporter.cs
- MimeFormReflector.cs
- GenericUriParser.cs
- ClassicBorderDecorator.cs
- ToolZone.cs
- SelectionItemProviderWrapper.cs
- AttributeAction.cs
- OperandQuery.cs
- TearOffProxy.cs
- BufferedGraphicsContext.cs
- Matrix3D.cs
- ServiceReference.cs
- TriggerBase.cs
- MissingManifestResourceException.cs
- ComponentDispatcherThread.cs
- __FastResourceComparer.cs
- CharKeyFrameCollection.cs
- DetailsViewInsertedEventArgs.cs
- SqlIdentifier.cs
- MetadataStore.cs
- NameValueCollection.cs
- WebBrowserUriTypeConverter.cs
- SQLDoubleStorage.cs
- EndpointPerformanceCounters.cs
- CompilerScope.Storage.cs
- UIElement.cs
- PropertyChangedEventManager.cs
- SessionStateUtil.cs
- GlobalizationSection.cs
- AppDomainFactory.cs
- Int32AnimationBase.cs
- ModelEditingScope.cs
- SoapServerMethod.cs
- HtmlTextArea.cs
- OdbcUtils.cs
- DeleteHelper.cs
- DbReferenceCollection.cs
- EventLogEntry.cs
- AutomationPropertyInfo.cs
- SecureEnvironment.cs
- HebrewCalendar.cs
- DocumentPropertiesDialog.cs
- PointConverter.cs
- HttpCachePolicyBase.cs
- LogStore.cs
- CorrelationService.cs
- KnownTypes.cs
- CellTreeNode.cs
- DetailsViewRow.cs
- SqlMultiplexer.cs
- WindowsGraphicsCacheManager.cs
- BinaryMethodMessage.cs
- ReadOnlyCollectionBase.cs
- LinqDataSourceContextData.cs
- SoapReflectionImporter.cs