Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / 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
- AsymmetricSignatureDeformatter.cs
- PathSegmentCollection.cs
- ParameterCollection.cs
- IsolatedStorageException.cs
- BitmapData.cs
- XmlReaderSettings.cs
- Funcletizer.cs
- MachineSettingsSection.cs
- Sentence.cs
- WindowsScrollBarBits.cs
- Rotation3D.cs
- PackageFilter.cs
- DateTimeConverter.cs
- StringConcat.cs
- EmbeddedMailObject.cs
- _ServiceNameStore.cs
- FontClient.cs
- AsyncResult.cs
- GridEntryCollection.cs
- RegexCompiler.cs
- DefaultParameterValueAttribute.cs
- TypeUtils.cs
- WindowsRegion.cs
- URLMembershipCondition.cs
- ProviderConnectionPointCollection.cs
- MetabaseServerConfig.cs
- XmlResolver.cs
- FormParameter.cs
- SqlAliasesReferenced.cs
- PageStatePersister.cs
- HttpClientCredentialType.cs
- ToolStripControlHost.cs
- HandledMouseEvent.cs
- SqlConnectionPoolProviderInfo.cs
- DesignUtil.cs
- BamlTreeNode.cs
- XamlPointCollectionSerializer.cs
- SqlRowUpdatingEvent.cs
- ByteKeyFrameCollection.cs
- EntityCommandDefinition.cs
- FunctionDetailsReader.cs
- DefaultTextStoreTextComposition.cs
- Regex.cs
- ToolStripOverflowButton.cs
- ReadOnlyTernaryTree.cs
- MonthCalendar.cs
- CssClassPropertyAttribute.cs
- SimpleMailWebEventProvider.cs
- SafeWaitHandle.cs
- TagMapInfo.cs
- InstallerTypeAttribute.cs
- InfoCardRSAPKCS1SignatureFormatter.cs
- TreeNodeSelectionProcessor.cs
- BaseTypeViewSchema.cs
- AstTree.cs
- ContainerControlDesigner.cs
- Int64.cs
- DataGridColumnCollectionEditor.cs
- WmlValidatorAdapter.cs
- AdRotator.cs
- BoundPropertyEntry.cs
- DataListCommandEventArgs.cs
- SessionParameter.cs
- PrimitiveDataContract.cs
- PolyQuadraticBezierSegment.cs
- PageHandlerFactory.cs
- GcHandle.cs
- UnmanagedHandle.cs
- SectionXmlInfo.cs
- ClientBuildManagerCallback.cs
- DispatcherHooks.cs
- Array.cs
- ApplicationInterop.cs
- DelayedRegex.cs
- FormsAuthenticationCredentials.cs
- HandlerMappingMemo.cs
- GregorianCalendarHelper.cs
- CustomErrorCollection.cs
- WorkflowApplication.cs
- BamlTreeNode.cs
- HotSpot.cs
- BlurEffect.cs
- BaseTransportHeaders.cs
- BoolExpression.cs
- CapabilitiesState.cs
- WSHttpTransportSecurityElement.cs
- DefaultBindingPropertyAttribute.cs
- MexNamedPipeBindingCollectionElement.cs
- RegexWorker.cs
- DateTimeUtil.cs
- dataprotectionpermission.cs
- XmlSerializerAssemblyAttribute.cs
- SoapAttributeAttribute.cs
- WeakReferenceEnumerator.cs
- AutoCompleteStringCollection.cs
- WindowsListViewGroupHelper.cs
- XmlCharacterData.cs
- DataKey.cs
- DefaultTextStoreTextComposition.cs
- MobileControlsSection.cs