Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / CompMod / Microsoft / Win32 / SafeHandles / SafeLibraryHandle.cs / 1305376 / 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; using System.Runtime.Versioning; 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)] [ResourceExposure(ResourceScope.Machine)] internal static extern SafeLibraryHandle LoadLibraryEx(string libFilename, IntPtr reserved, int flags); [DllImport(ExternDll.Kernel32, CharSet=System.Runtime.InteropServices.CharSet.Unicode)] [ResourceExposure(ResourceScope.None)] [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; using System.Runtime.Versioning; 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)] [ResourceExposure(ResourceScope.Machine)] internal static extern SafeLibraryHandle LoadLibraryEx(string libFilename, IntPtr reserved, int flags); [DllImport(ExternDll.Kernel32, CharSet=System.Runtime.InteropServices.CharSet.Unicode)] [ResourceExposure(ResourceScope.None)] [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
- StrokeCollection.cs
- SqlClientWrapperSmiStream.cs
- ConnectionStringsExpressionBuilder.cs
- Font.cs
- MsmqInputChannelListener.cs
- XmlDocumentType.cs
- DBAsyncResult.cs
- ECDsaCng.cs
- ScriptBehaviorDescriptor.cs
- PkcsUtils.cs
- CmsUtils.cs
- RawUIStateInputReport.cs
- RangeValuePatternIdentifiers.cs
- HttpResponseWrapper.cs
- DropDownList.cs
- HashHelper.cs
- SqlCharStream.cs
- ExternalException.cs
- WorkflowInstanceExtensionCollection.cs
- RecipientInfo.cs
- ThicknessAnimationBase.cs
- EntityTemplateUserControl.cs
- RelationshipFixer.cs
- XmlTextReader.cs
- WebBrowserHelper.cs
- TagPrefixCollection.cs
- XmlNamespaceDeclarationsAttribute.cs
- ModelItemCollection.cs
- OutOfProcStateClientManager.cs
- ColorConverter.cs
- InternalBase.cs
- TimeStampChecker.cs
- ContravarianceAdapter.cs
- UserMapPath.cs
- Claim.cs
- SynchronizedInputHelper.cs
- ButtonFlatAdapter.cs
- SortExpressionBuilder.cs
- FormViewModeEventArgs.cs
- Encoder.cs
- CaretElement.cs
- ClientData.cs
- TypeLoadException.cs
- FirewallWrapper.cs
- XPathScanner.cs
- FileSystemEventArgs.cs
- TriState.cs
- TreeNode.cs
- AutoFocusStyle.xaml.cs
- BaseResourcesBuildProvider.cs
- SQLInt16Storage.cs
- ArgumentNullException.cs
- KeyEvent.cs
- ElementNotAvailableException.cs
- ScrollEvent.cs
- LoadRetryHandler.cs
- UrlAuthFailedErrorFormatter.cs
- OutOfProcStateClientManager.cs
- ModuleElement.cs
- RefreshResponseInfo.cs
- PersonalizationStateQuery.cs
- ListViewItem.cs
- DesignerView.xaml.cs
- SchemaObjectWriter.cs
- CanonicalXml.cs
- CharacterString.cs
- ClassHandlersStore.cs
- util.cs
- AssemblyCache.cs
- SqlNodeAnnotation.cs
- TypeDescriptorFilterService.cs
- ConsoleTraceListener.cs
- MimeParameter.cs
- SqlCacheDependency.cs
- SqlConnectionHelper.cs
- ErrorTolerantObjectWriter.cs
- SqlTopReducer.cs
- ActivityCollectionMarkupSerializer.cs
- DashStyle.cs
- RegexBoyerMoore.cs
- FtpCachePolicyElement.cs
- WorkflowRuntime.cs
- MembershipValidatePasswordEventArgs.cs
- GetUserPreferenceRequest.cs
- XappLauncher.cs
- ToolboxItemAttribute.cs
- DocumentPageView.cs
- SiblingIterators.cs
- PermissionAttributes.cs
- SevenBitStream.cs
- DataGridViewCellLinkedList.cs
- XPathItem.cs
- RtfToXamlLexer.cs
- AsyncStreamReader.cs
- HostProtectionException.cs
- coordinatorfactory.cs
- StatusBarItemAutomationPeer.cs
- InternalException.cs
- XmlSchemaSimpleType.cs
- EventDrivenDesigner.cs