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
- Processor.cs
- TextAdaptor.cs
- RoleManagerSection.cs
- TypeElement.cs
- XmlIterators.cs
- XmlSchemaComplexContentExtension.cs
- WindowsImpersonationContext.cs
- ProvideValueServiceProvider.cs
- ClientSettingsSection.cs
- CustomPopupPlacement.cs
- PrintController.cs
- ChangeProcessor.cs
- DefaultObjectSerializer.cs
- UidPropertyAttribute.cs
- WebPartHelpVerb.cs
- DependencyObjectValidator.cs
- AccessText.cs
- OletxVolatileEnlistment.cs
- XmlStreamStore.cs
- Rectangle.cs
- WindowsAuthenticationEventArgs.cs
- WindowsIdentity.cs
- DesignSurfaceServiceContainer.cs
- RegexCompiler.cs
- HttpPostLocalhostServerProtocol.cs
- UdpDiscoveryEndpointProvider.cs
- Single.cs
- BitmapDecoder.cs
- TableChangeProcessor.cs
- LinkTarget.cs
- EditorZone.cs
- CodeCommentStatementCollection.cs
- Predicate.cs
- ImageSourceConverter.cs
- ValidationPropertyAttribute.cs
- WindowsFont.cs
- Constraint.cs
- TransformValueSerializer.cs
- XmlSigningNodeWriter.cs
- XmlSchemaSimpleContentExtension.cs
- IsolatedStorage.cs
- UnmanagedBitmapWrapper.cs
- ProcessModelSection.cs
- NameValueSectionHandler.cs
- ScrollChangedEventArgs.cs
- LookupNode.cs
- WeakReference.cs
- ReachSerializationCacheItems.cs
- DrawingBrush.cs
- SQLSingleStorage.cs
- Operand.cs
- Double.cs
- Opcode.cs
- ReadOnlyCollection.cs
- HtmlLink.cs
- SafeLibraryHandle.cs
- _SafeNetHandles.cs
- ResourceContainer.cs
- RegisteredExpandoAttribute.cs
- NamedObject.cs
- ImageCollectionEditor.cs
- DocumentSequenceHighlightLayer.cs
- ExternalDataExchangeService.cs
- RenameRuleObjectDialog.cs
- SvcFileManager.cs
- SafeEventLogWriteHandle.cs
- MemberDomainMap.cs
- NamedElement.cs
- TableMethodGenerator.cs
- RowToParametersTransformer.cs
- BoolLiteral.cs
- LowerCaseStringConverter.cs
- NameValueConfigurationCollection.cs
- CryptoStream.cs
- VisualBasicHelper.cs
- AssociationTypeEmitter.cs
- SizeF.cs
- ImageMetadata.cs
- UriSectionReader.cs
- sqlnorm.cs
- GeneralTransform3DGroup.cs
- LowerCaseStringConverter.cs
- ContainerFilterService.cs
- jithelpers.cs
- ResourceSetExpression.cs
- Span.cs
- XmlTextWriter.cs
- ReadOnlyDictionary.cs
- WindowsUpDown.cs
- versioninfo.cs
- URLString.cs
- PerformanceCounterManager.cs
- PrintController.cs
- AppSettingsSection.cs
- MiniConstructorInfo.cs
- InheritanceRules.cs
- ValidationResult.cs
- MetadataStore.cs
- sqlinternaltransaction.cs
- TabControl.cs