Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / 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
- LinearKeyFrames.cs
- FixedSOMGroup.cs
- SafeHandle.cs
- TemplateControl.cs
- Switch.cs
- Context.cs
- _ServiceNameStore.cs
- LocatorPart.cs
- ToolBar.cs
- DataServiceRequestOfT.cs
- AppliedDeviceFiltersEditor.cs
- GridViewUpdateEventArgs.cs
- BinaryEditor.cs
- ToolStripDropDownMenu.cs
- ImageIndexEditor.cs
- RepeatInfo.cs
- MarkerProperties.cs
- wmiprovider.cs
- UserControlParser.cs
- WebScriptMetadataMessage.cs
- ColorMatrix.cs
- SequenceDesigner.cs
- MenuItemAutomationPeer.cs
- SafeNativeMethods.cs
- AdRotator.cs
- ProxyHwnd.cs
- EntityDesignerBuildProvider.cs
- HtmlButton.cs
- CustomActivityDesigner.cs
- CompositeCollection.cs
- WorkflowServiceHostFactory.cs
- OpenTypeCommon.cs
- TableSectionStyle.cs
- ComplexTypeEmitter.cs
- PkcsUtils.cs
- dbdatarecord.cs
- ResourceDescriptionAttribute.cs
- TraceSwitch.cs
- XmlQueryContext.cs
- CompilerErrorCollection.cs
- TokenBasedSet.cs
- OrderPreservingPipeliningMergeHelper.cs
- ZipArchive.cs
- DataSourceXmlAttributeAttribute.cs
- ProxyWebPart.cs
- ValidationHelper.cs
- BreakRecordTable.cs
- KeyValueConfigurationCollection.cs
- NumberFunctions.cs
- LessThanOrEqual.cs
- DbBuffer.cs
- ListViewSelectEventArgs.cs
- SiteMapNodeCollection.cs
- LongTypeConverter.cs
- CollectionChangeEventArgs.cs
- FormsAuthenticationUserCollection.cs
- FileAccessException.cs
- ConfigUtil.cs
- BindingSource.cs
- TransformBlockRequest.cs
- InstanceDataCollection.cs
- ControlPaint.cs
- ButtonField.cs
- ProviderUtil.cs
- ColorTransformHelper.cs
- TripleDESCryptoServiceProvider.cs
- WebPartCloseVerb.cs
- ResourceDictionary.cs
- BooleanAnimationUsingKeyFrames.cs
- FormViewInsertedEventArgs.cs
- Activator.cs
- AsyncOperationContext.cs
- ViewCellRelation.cs
- TransformerInfoCollection.cs
- OleDbReferenceCollection.cs
- ToolStripRendererSwitcher.cs
- Base64Stream.cs
- StringStorage.cs
- HtmlTextArea.cs
- GifBitmapDecoder.cs
- TransactionProxy.cs
- ScriptResourceInfo.cs
- Iis7Helper.cs
- KeyNotFoundException.cs
- XmlDataImplementation.cs
- DateTimeOffsetStorage.cs
- PaginationProgressEventArgs.cs
- ScriptControlDescriptor.cs
- X509Utils.cs
- ValidationError.cs
- MemberListBinding.cs
- Fonts.cs
- DataTableCollection.cs
- ToolStripOverflowButton.cs
- Int32Collection.cs
- StrongNamePublicKeyBlob.cs
- AsymmetricKeyExchangeDeformatter.cs
- CallbackHandler.cs
- prompt.cs
- ObjectDisposedException.cs