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
- EntityDataSourceViewSchema.cs
- AtomPub10CategoriesDocumentFormatter.cs
- WebPartDisplayModeCancelEventArgs.cs
- StrokeCollectionDefaultValueFactory.cs
- ScalarType.cs
- ResourceCategoryAttribute.cs
- SqlDataReader.cs
- BufferedGraphics.cs
- NamedPermissionSet.cs
- _Win32.cs
- EntityDataSourceChangedEventArgs.cs
- ForeignKeyConstraint.cs
- Drawing.cs
- FormViewDeleteEventArgs.cs
- XmlSchemaAppInfo.cs
- ElementFactory.cs
- StreamGeometry.cs
- ConnectionProviderAttribute.cs
- ImageClickEventArgs.cs
- ReadOnlyPropertyMetadata.cs
- SamlAudienceRestrictionCondition.cs
- _SpnDictionary.cs
- SqlTypesSchemaImporter.cs
- ServiceDesigner.cs
- _StreamFramer.cs
- Margins.cs
- LocalIdCollection.cs
- BaseInfoTable.cs
- TableRowGroupCollection.cs
- odbcmetadatacollectionnames.cs
- ProfileBuildProvider.cs
- SafeProcessHandle.cs
- XmlRootAttribute.cs
- WMICapabilities.cs
- ChtmlTextWriter.cs
- ChangePassword.cs
- TextDecorations.cs
- BamlResourceContent.cs
- M3DUtil.cs
- CharacterHit.cs
- SemanticAnalyzer.cs
- SimplePropertyEntry.cs
- BaseProcessor.cs
- WindowsListBox.cs
- PassportIdentity.cs
- IInstanceTable.cs
- IndentTextWriter.cs
- XpsSerializerWriter.cs
- TimeSpanStorage.cs
- X509WindowsSecurityToken.cs
- BindingSource.cs
- SystemInfo.cs
- XmlSchemaGroupRef.cs
- PolicyStatement.cs
- CroppedBitmap.cs
- Stylesheet.cs
- UnsettableComboBox.cs
- RootNamespaceAttribute.cs
- Opcode.cs
- AuthorizationRule.cs
- StringFunctions.cs
- ResponseStream.cs
- StyleTypedPropertyAttribute.cs
- SqlReorderer.cs
- DataGridCommandEventArgs.cs
- SqlDataSourceEnumerator.cs
- Vector3D.cs
- Int32RectConverter.cs
- ToolStripItemClickedEventArgs.cs
- ComboBoxRenderer.cs
- EntityDataSourceContextDisposingEventArgs.cs
- DefaultAssemblyResolver.cs
- ChoiceConverter.cs
- SplitterPanel.cs
- Opcode.cs
- StateManager.cs
- PersonalizationStateInfo.cs
- WebGetAttribute.cs
- RootCodeDomSerializer.cs
- Assert.cs
- Normalization.cs
- MetadataItem.cs
- IndentedWriter.cs
- PersistChildrenAttribute.cs
- EntryPointNotFoundException.cs
- CheckedListBox.cs
- ColorMap.cs
- WorkflowApplicationUnloadedException.cs
- CompilerLocalReference.cs
- PrtCap_Base.cs
- IItemContainerGenerator.cs
- CatalogZoneBase.cs
- XmlSchemaSequence.cs
- RecordBuilder.cs
- ProfileSection.cs
- documentsequencetextcontainer.cs
- SqlGenerator.cs
- CompressEmulationStream.cs
- MissingMemberException.cs
- ClientBuildManagerCallback.cs