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
- RuleAttributes.cs
- X509Utils.cs
- HelpProvider.cs
- WorkItem.cs
- MachineKey.cs
- Exceptions.cs
- RepeatInfo.cs
- SocketInformation.cs
- CodeSnippetStatement.cs
- DbDataSourceEnumerator.cs
- CommandBindingCollection.cs
- FixedSOMImage.cs
- GeometryDrawing.cs
- OrderByBuilder.cs
- EntityClientCacheKey.cs
- QilVisitor.cs
- SmtpLoginAuthenticationModule.cs
- EndPoint.cs
- RadioButtonDesigner.cs
- SecuritySessionClientSettings.cs
- NameValueConfigurationElement.cs
- ProcessInfo.cs
- BinaryUtilClasses.cs
- OrderedDictionary.cs
- BamlWriter.cs
- X509CertificateClaimSet.cs
- WebPartConnectionsConnectVerb.cs
- CatalogZoneBase.cs
- _NegoState.cs
- AssociationTypeEmitter.cs
- InheritanceAttribute.cs
- EventHandlingScope.cs
- AsymmetricKeyExchangeFormatter.cs
- ZipPackagePart.cs
- indexingfiltermarshaler.cs
- WebPartCancelEventArgs.cs
- ApplicationFileCodeDomTreeGenerator.cs
- ImmutableCollection.cs
- SqlDataSourceConfigureFilterForm.cs
- XpsSerializationManagerAsync.cs
- BufferedReadStream.cs
- TimeoutException.cs
- ApplicationServicesHostFactory.cs
- TextTabProperties.cs
- DbModificationCommandTree.cs
- WebProxyScriptElement.cs
- DbConnectionPoolGroup.cs
- DbBuffer.cs
- InputLanguageEventArgs.cs
- CultureSpecificCharacterBufferRange.cs
- Mapping.cs
- TextChange.cs
- StructuredProperty.cs
- StateDesigner.LayoutSelectionGlyph.cs
- ResourceCodeDomSerializer.cs
- VSDExceptions.cs
- GridItemCollection.cs
- QilParameter.cs
- EpmContentDeSerializerBase.cs
- HttpWebResponse.cs
- DispatcherObject.cs
- SizeChangedEventArgs.cs
- SystemWebCachingSectionGroup.cs
- VectorCollection.cs
- FileDataSourceCache.cs
- UrlParameterReader.cs
- DefaultSerializationProviderAttribute.cs
- ValidationResult.cs
- WebEventTraceProvider.cs
- AnimationClockResource.cs
- SocketException.cs
- TableCell.cs
- RtfControls.cs
- PersistNameAttribute.cs
- PtsCache.cs
- XmlSchemaValidationException.cs
- MessageBox.cs
- ConfigurationConverterBase.cs
- Stack.cs
- _SslStream.cs
- ExeContext.cs
- Point4D.cs
- MemoryStream.cs
- ContextMenuAutomationPeer.cs
- ExceptionTrace.cs
- PrintController.cs
- QilFunction.cs
- RequestReplyCorrelator.cs
- SafeRegistryHandle.cs
- ConfigurationElement.cs
- TabControlEvent.cs
- SafeRightsManagementHandle.cs
- Enum.cs
- DisplayInformation.cs
- BinHexEncoder.cs
- DataGridViewLayoutData.cs
- _SslSessionsCache.cs
- TableMethodGenerator.cs
- WebEventCodes.cs
- StandardMenuStripVerb.cs