Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / CompMod / Microsoft / Win32 / SafeHandles / SafeEventLogReadHandle.cs / 1305376 / SafeEventLogReadHandle.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== /*============================================================ ** ** Class: SafeEventLogReadHandle ** **Author: David Gutierrez ([....]) ** ** A wrapper for event log 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 SafeEventLogReadHandle : SafeHandleZeroOrMinusOneIsInvalid { // Note: OpenEventLog returns 0 on failure. internal SafeEventLogReadHandle () : base(true) { } [DllImport(ExternDll.Advapi32, CharSet=System.Runtime.InteropServices.CharSet.Unicode, SetLastError=true)] [ResourceExposure(ResourceScope.Machine)] internal static extern SafeEventLogReadHandle OpenEventLog(string UNCServerName, string sourceName); [DllImport(ExternDll.Advapi32, SetLastError=true)] [ResourceExposure(ResourceScope.None)] [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] private static extern bool CloseEventLog(IntPtr hEventLog); override protected bool ReleaseHandle() { return CloseEventLog(handle); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== /*============================================================ ** ** Class: SafeEventLogReadHandle ** **Author: David Gutierrez ([....]) ** ** A wrapper for event log 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 SafeEventLogReadHandle : SafeHandleZeroOrMinusOneIsInvalid { // Note: OpenEventLog returns 0 on failure. internal SafeEventLogReadHandle () : base(true) { } [DllImport(ExternDll.Advapi32, CharSet=System.Runtime.InteropServices.CharSet.Unicode, SetLastError=true)] [ResourceExposure(ResourceScope.Machine)] internal static extern SafeEventLogReadHandle OpenEventLog(string UNCServerName, string sourceName); [DllImport(ExternDll.Advapi32, SetLastError=true)] [ResourceExposure(ResourceScope.None)] [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] private static extern bool CloseEventLog(IntPtr hEventLog); override protected bool ReleaseHandle() { return CloseEventLog(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
- ToolStripContentPanelDesigner.cs
- DataServices.cs
- XamlTypeMapper.cs
- ToolStripScrollButton.cs
- ByteStreamMessage.cs
- StructuredTypeInfo.cs
- ToolStripPanelRenderEventArgs.cs
- SatelliteContractVersionAttribute.cs
- DescendentsWalker.cs
- PersistChildrenAttribute.cs
- TagElement.cs
- DNS.cs
- MemberDescriptor.cs
- BitmapEffectInputConnector.cs
- smtppermission.cs
- XPathExpr.cs
- ReadOnlyDictionary.cs
- TextTreePropertyUndoUnit.cs
- ObjectCacheHost.cs
- ZoneButton.cs
- WebSysDisplayNameAttribute.cs
- XsltQilFactory.cs
- SqlBooleanizer.cs
- dsa.cs
- AssemblyBuilderData.cs
- KeyboardDevice.cs
- SemaphoreFullException.cs
- DataFormats.cs
- EntityParameterCollection.cs
- ThaiBuddhistCalendar.cs
- SingleKeyFrameCollection.cs
- URLMembershipCondition.cs
- FormView.cs
- OutputCacheProviderCollection.cs
- CalloutQueueItem.cs
- MouseWheelEventArgs.cs
- ResourcesBuildProvider.cs
- DbTypeMap.cs
- PageContentCollection.cs
- BinaryMessageFormatter.cs
- IgnoreSectionHandler.cs
- CellRelation.cs
- HttpRuntime.cs
- CreatingCookieEventArgs.cs
- StaticSiteMapProvider.cs
- SourceItem.cs
- _OSSOCK.cs
- AccessibleObject.cs
- XmlSchemaType.cs
- BinaryFormatter.cs
- Errors.cs
- JoinSymbol.cs
- URLMembershipCondition.cs
- DiagnosticTrace.cs
- XmlSchemas.cs
- XmlEntityReference.cs
- HtmlControlDesigner.cs
- PingOptions.cs
- OptimalBreakSession.cs
- WebBrowserSiteBase.cs
- Random.cs
- PropertyExpression.cs
- InputBuffer.cs
- Parameter.cs
- XmlQualifiedName.cs
- WindowsButton.cs
- SignatureGenerator.cs
- BookmarkEventArgs.cs
- HtmlUtf8RawTextWriter.cs
- ListViewGroupCollectionEditor.cs
- ExeContext.cs
- CollectionChangeEventArgs.cs
- XhtmlTextWriter.cs
- ResolveDuplexCD1AsyncResult.cs
- ResXResourceWriter.cs
- PasswordRecovery.cs
- TabItemAutomationPeer.cs
- _OSSOCK.cs
- CompatibleComparer.cs
- ArrayWithOffset.cs
- ToolStripItemRenderEventArgs.cs
- Form.cs
- VScrollProperties.cs
- TypeLibConverter.cs
- DependencyObjectType.cs
- SByteConverter.cs
- ExcCanonicalXml.cs
- IPAddressCollection.cs
- MultitargetUtil.cs
- WebService.cs
- ArithmeticException.cs
- hresults.cs
- TreeNodeMouseHoverEvent.cs
- UnmanagedMarshal.cs
- NodeLabelEditEvent.cs
- LicenseContext.cs
- Transform3DGroup.cs
- BufferBuilder.cs
- FileUtil.cs
- PackageRelationshipSelector.cs