Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Core / System / Diagnostics / Eventing / Reader / EventLogHandle.cs / 1305376 / EventLogHandle.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== /*============================================================ ** ** Class: EventLogHandle ** ** Purpose: ** This internal class is a SafeHandle implementation over a ** native EVT_HANDLE - obtained from EventLog Native Methods. ** ============================================================*/ using System; using System.Runtime.InteropServices; using System.Security.Permissions; namespace System.Diagnostics.Eventing.Reader { // // Marked as SecurityCritical due to link demands from inherited // SafeHandle members. // // marked as Safe since the only real operation that is performed // by this class is NativeWrapper.EvtClose and that is protected // by a full Demand() before doing any work. [System.Security.SecuritySafeCritical] internal sealed class EventLogHandle : SafeHandle { // Called by P/Invoke when returning SafeHandles private EventLogHandle() : base(IntPtr.Zero, true) { } internal EventLogHandle(IntPtr handle, bool ownsHandle) : base(IntPtr.Zero, ownsHandle) { SetHandle(handle); } public override bool IsInvalid { get { return IsClosed || handle == IntPtr.Zero; } } protected override bool ReleaseHandle() { NativeWrapper.EvtClose(handle); handle = IntPtr.Zero; return true; } // DONT compare EventLogHandle with EventLogHandle.Zero // use IsInvalid instead. Zero is provided where a NULL handle needed public static EventLogHandle Zero { get { return new EventLogHandle(); } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== /*============================================================ ** ** Class: EventLogHandle ** ** Purpose: ** This internal class is a SafeHandle implementation over a ** native EVT_HANDLE - obtained from EventLog Native Methods. ** ============================================================*/ using System; using System.Runtime.InteropServices; using System.Security.Permissions; namespace System.Diagnostics.Eventing.Reader { // // Marked as SecurityCritical due to link demands from inherited // SafeHandle members. // // marked as Safe since the only real operation that is performed // by this class is NativeWrapper.EvtClose and that is protected // by a full Demand() before doing any work. [System.Security.SecuritySafeCritical] internal sealed class EventLogHandle : SafeHandle { // Called by P/Invoke when returning SafeHandles private EventLogHandle() : base(IntPtr.Zero, true) { } internal EventLogHandle(IntPtr handle, bool ownsHandle) : base(IntPtr.Zero, ownsHandle) { SetHandle(handle); } public override bool IsInvalid { get { return IsClosed || handle == IntPtr.Zero; } } protected override bool ReleaseHandle() { NativeWrapper.EvtClose(handle); handle = IntPtr.Zero; return true; } // DONT compare EventLogHandle with EventLogHandle.Zero // use IsInvalid instead. Zero is provided where a NULL handle needed public static EventLogHandle Zero { get { return new EventLogHandle(); } } } } // 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
- Serializer.cs
- DependencyPropertyChangedEventArgs.cs
- CodeEntryPointMethod.cs
- DataGridItem.cs
- ScrollBarAutomationPeer.cs
- BindingOperations.cs
- CapabilitiesRule.cs
- MappingException.cs
- FormatException.cs
- WebAdminConfigurationHelper.cs
- XmlLanguage.cs
- UserPreferenceChangedEventArgs.cs
- KeySplineConverter.cs
- ByteConverter.cs
- Utils.cs
- WebServiceErrorEvent.cs
- BinaryFormatter.cs
- UpDownBase.cs
- X509CertificateInitiatorClientCredential.cs
- ZipIOExtraFieldZip64Element.cs
- AnimationClockResource.cs
- DataGridPageChangedEventArgs.cs
- DataGridViewEditingControlShowingEventArgs.cs
- OutputCacheProfile.cs
- TextViewElement.cs
- CodeBlockBuilder.cs
- XmlSchemaSimpleContentExtension.cs
- FormViewCommandEventArgs.cs
- ExpandSegment.cs
- PersonalizablePropertyEntry.cs
- FormsIdentity.cs
- TaiwanCalendar.cs
- ReflectionUtil.cs
- BamlLocalizer.cs
- SplashScreenNativeMethods.cs
- FormsAuthenticationConfiguration.cs
- XPathNavigatorReader.cs
- Comparer.cs
- SessionEndingCancelEventArgs.cs
- HashCodeCombiner.cs
- _DigestClient.cs
- BuildProvider.cs
- ColumnTypeConverter.cs
- DockPanel.cs
- DataGridViewComboBoxColumn.cs
- EntityDataSourceViewSchema.cs
- RepeatInfo.cs
- PropertyEmitter.cs
- dataobject.cs
- ElementMarkupObject.cs
- DocumentApplication.cs
- XmlSchemaSet.cs
- UserNameServiceElement.cs
- DoubleAnimationUsingKeyFrames.cs
- ProviderSettingsCollection.cs
- ValueSerializerAttribute.cs
- ParenthesizePropertyNameAttribute.cs
- Button.cs
- RawUIStateInputReport.cs
- PageRanges.cs
- Drawing.cs
- HexParser.cs
- DataGridViewRow.cs
- HttpRuntime.cs
- VarRemapper.cs
- typedescriptorpermissionattribute.cs
- MulticastNotSupportedException.cs
- XmlNamedNodeMap.cs
- FrugalMap.cs
- DataGridViewTextBoxColumn.cs
- DBCommand.cs
- SqlCacheDependencyDatabase.cs
- MethodToken.cs
- ELinqQueryState.cs
- EncodingTable.cs
- NewArray.cs
- UnsafeNativeMethods.cs
- DynamicContractTypeBuilder.cs
- BitmapImage.cs
- CuspData.cs
- EditCommandColumn.cs
- DiscoveryMessageSequenceGenerator.cs
- PointIndependentAnimationStorage.cs
- ShaderEffect.cs
- Permission.cs
- SchemaImporterExtensionElement.cs
- ModelServiceImpl.cs
- ResourceDescriptionAttribute.cs
- PrivilegeNotHeldException.cs
- CreateParams.cs
- ServiceBusyException.cs
- FilterEventArgs.cs
- PropertyInformation.cs
- EntityExpressionVisitor.cs
- ExpandableObjectConverter.cs
- ConstNode.cs
- BlockCollection.cs
- FormatException.cs
- Atom10FormatterFactory.cs
- BaseProcessor.cs