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 / SafeEventLogWriteHandle.cs / 1 / SafeEventLogWriteHandle.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== /*============================================================ ** ** Class: SafeEventLogWriteHandle ** **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; namespace Microsoft.Win32.SafeHandles { [HostProtectionAttribute(MayLeakOnAbort = true)] [SuppressUnmanagedCodeSecurityAttribute] internal sealed class SafeEventLogWriteHandle : SafeHandleZeroOrMinusOneIsInvalid { // Note: RegisterEventSource returns 0 on failure internal SafeEventLogWriteHandle () : base(true) {} [DllImport(ExternDll.Advapi32, CharSet=System.Runtime.InteropServices.CharSet.Unicode, SetLastError=true)] internal static extern SafeEventLogWriteHandle RegisterEventSource(string uncServerName, string sourceName); [DllImport(ExternDll.Advapi32, SetLastError=true)] [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] private static extern bool DeregisterEventSource(IntPtr hEventLog); override protected bool ReleaseHandle() { return DeregisterEventSource(handle); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== /*============================================================ ** ** Class: SafeEventLogWriteHandle ** **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; namespace Microsoft.Win32.SafeHandles { [HostProtectionAttribute(MayLeakOnAbort = true)] [SuppressUnmanagedCodeSecurityAttribute] internal sealed class SafeEventLogWriteHandle : SafeHandleZeroOrMinusOneIsInvalid { // Note: RegisterEventSource returns 0 on failure internal SafeEventLogWriteHandle () : base(true) {} [DllImport(ExternDll.Advapi32, CharSet=System.Runtime.InteropServices.CharSet.Unicode, SetLastError=true)] internal static extern SafeEventLogWriteHandle RegisterEventSource(string uncServerName, string sourceName); [DllImport(ExternDll.Advapi32, SetLastError=true)] [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] private static extern bool DeregisterEventSource(IntPtr hEventLog); override protected bool ReleaseHandle() { return DeregisterEventSource(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
- CapabilitiesRule.cs
- BaseAppDomainProtocolHandler.cs
- TextTreeUndoUnit.cs
- MarkupCompilePass1.cs
- FtpWebRequest.cs
- DateBoldEvent.cs
- EventHandlersStore.cs
- OutputCacheModule.cs
- LayoutEvent.cs
- ellipse.cs
- AccessViolationException.cs
- ConfigurationProperty.cs
- SourceFilter.cs
- ResourceDisplayNameAttribute.cs
- DbgUtil.cs
- EventSinkHelperWriter.cs
- FileDetails.cs
- StringFunctions.cs
- CapabilitiesRule.cs
- TickBar.cs
- ResourcesGenerator.cs
- SecurityMode.cs
- Figure.cs
- dataprotectionpermission.cs
- WebPartTransformer.cs
- ComponentResourceKey.cs
- IndicShape.cs
- Figure.cs
- BuildProviderAppliesToAttribute.cs
- GlyphRunDrawing.cs
- GZipDecoder.cs
- NameValueFileSectionHandler.cs
- ResourceReferenceKeyNotFoundException.cs
- Pair.cs
- PropertyGroupDescription.cs
- SubMenuStyle.cs
- WebMessageBodyStyleHelper.cs
- CfgRule.cs
- TraceHandler.cs
- CellPartitioner.cs
- QEncodedStream.cs
- TextBreakpoint.cs
- ProcessHostFactoryHelper.cs
- ProcessHostServerConfig.cs
- RuleProcessor.cs
- SmtpSpecifiedPickupDirectoryElement.cs
- EmbeddedObject.cs
- EntitySqlQueryCacheKey.cs
- EndpointInfoCollection.cs
- RegisteredArrayDeclaration.cs
- Link.cs
- StickyNoteAnnotations.cs
- BookmarkScopeHandle.cs
- ObjectListDesigner.cs
- InfoCardCryptoHelper.cs
- AlphabeticalEnumConverter.cs
- XmlTextReaderImpl.cs
- XmlDomTextWriter.cs
- MatchingStyle.cs
- MonitorWrapper.cs
- ArraySubsetEnumerator.cs
- WindowsFormsSectionHandler.cs
- IgnoreSectionHandler.cs
- PTManager.cs
- __ConsoleStream.cs
- webproxy.cs
- SessionStateContainer.cs
- AndMessageFilterTable.cs
- EventData.cs
- CfgParser.cs
- Compiler.cs
- GCHandleCookieTable.cs
- MonthChangedEventArgs.cs
- WorkflowInstance.cs
- BamlBinaryWriter.cs
- ActivityTrace.cs
- DbDataRecord.cs
- MemberCollection.cs
- HttpException.cs
- AttributeXamlType.cs
- SaveFileDialog.cs
- SoapAttributes.cs
- AssemblyAssociatedContentFileAttribute.cs
- WebSysDefaultValueAttribute.cs
- LineBreakRecord.cs
- LinkUtilities.cs
- ContextStaticAttribute.cs
- DBConnection.cs
- PropertyCondition.cs
- WebPartConnection.cs
- AddressHeaderCollectionElement.cs
- EventHandlersStore.cs
- XmlSchemaObject.cs
- OdbcError.cs
- WindowsProgressbar.cs
- XPathNavigatorReader.cs
- ParseNumbers.cs
- ComponentEvent.cs
- IteratorDescriptor.cs
- DbExpressionRules.cs