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
- FixedSOMLineCollection.cs
- CertificateManager.cs
- Assert.cs
- SymLanguageType.cs
- WebBrowser.cs
- StringArrayConverter.cs
- Renderer.cs
- MethodCallConverter.cs
- ModelServiceImpl.cs
- Subtree.cs
- NamedPermissionSet.cs
- Decorator.cs
- OrderedDictionary.cs
- NativeMethods.cs
- UriScheme.cs
- SqlParameterizer.cs
- NavigationProperty.cs
- PrintDialog.cs
- mediaeventargs.cs
- ValueConversionAttribute.cs
- SiteMapSection.cs
- ToolStripContentPanelRenderEventArgs.cs
- DataSourceXmlSubItemAttribute.cs
- DataGridViewCellStyleContentChangedEventArgs.cs
- ProfileEventArgs.cs
- Reference.cs
- WebDisplayNameAttribute.cs
- CompilationUtil.cs
- AlgoModule.cs
- TreeViewAutomationPeer.cs
- BitConverter.cs
- OleDbPropertySetGuid.cs
- SqlFlattener.cs
- DatagridviewDisplayedBandsData.cs
- IncrementalCompileAnalyzer.cs
- AssemblyBuilder.cs
- HtmlTableRow.cs
- CalendarTable.cs
- HTMLTextWriter.cs
- InputScopeConverter.cs
- BrushMappingModeValidation.cs
- ComplexTypeEmitter.cs
- EventToken.cs
- CodeNamespaceImportCollection.cs
- WpfXamlLoader.cs
- DescendantOverDescendantQuery.cs
- XmlUtil.cs
- DefinitionBase.cs
- ErrorRuntimeConfig.cs
- codemethodreferenceexpression.cs
- ToolboxItemAttribute.cs
- DocumentXmlWriter.cs
- DataObjectPastingEventArgs.cs
- TimeoutValidationAttribute.cs
- ISAPIApplicationHost.cs
- UrlEncodedParameterWriter.cs
- ViewCellRelation.cs
- PointLightBase.cs
- TimeZone.cs
- WinInet.cs
- WebPartConnectionsCancelVerb.cs
- FrameworkElement.cs
- LeaseManager.cs
- NamedElement.cs
- WebEventCodes.cs
- ConfigXmlSignificantWhitespace.cs
- DecimalStorage.cs
- SqlDataSource.cs
- GradientStop.cs
- DesignerTextWriter.cs
- MeshGeometry3D.cs
- RtfControlWordInfo.cs
- IList.cs
- wmiutil.cs
- HandlerBase.cs
- EventManager.cs
- UriScheme.cs
- ToggleProviderWrapper.cs
- StartUpEventArgs.cs
- LineInfo.cs
- ProtocolException.cs
- DesignerVerb.cs
- WebPartEventArgs.cs
- _ProxyChain.cs
- SQlBooleanStorage.cs
- ExtensionSurface.cs
- InkPresenterAutomationPeer.cs
- messageonlyhwndwrapper.cs
- FixedSOMSemanticBox.cs
- BooleanStorage.cs
- SchemaCollectionPreprocessor.cs
- ActivityInstance.cs
- PasswordRecovery.cs
- ToolStripItem.cs
- LayoutManager.cs
- KerberosRequestorSecurityToken.cs
- WorkerRequest.cs
- XamlFrame.cs
- DatatypeImplementation.cs
- SectionInput.cs