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
- String.cs
- Vector3DCollection.cs
- ControlType.cs
- ProcessHostServerConfig.cs
- DataGridToolTip.cs
- RegisteredExpandoAttribute.cs
- TrackingAnnotationCollection.cs
- CacheEntry.cs
- HttpCacheVary.cs
- MatrixAnimationUsingPath.cs
- WithParamAction.cs
- PropertyInfoSet.cs
- ConditionCollection.cs
- SafeCryptoHandles.cs
- SqlSupersetValidator.cs
- DrawingImage.cs
- Codec.cs
- ReturnEventArgs.cs
- SoapWriter.cs
- SqlRetyper.cs
- XmlHierarchicalDataSourceView.cs
- nulltextnavigator.cs
- LocalizableResourceBuilder.cs
- OdbcUtils.cs
- AlternateView.cs
- DataPager.cs
- DeviceContexts.cs
- PriorityItem.cs
- Matrix3D.cs
- EventBuilder.cs
- WindowsImpersonationContext.cs
- MethodRental.cs
- MouseEvent.cs
- ReachFixedPageSerializerAsync.cs
- ProviderUtil.cs
- Int64AnimationBase.cs
- Misc.cs
- ReadOnlyNameValueCollection.cs
- Int64AnimationBase.cs
- GridEntry.cs
- SpellerStatusTable.cs
- JobPageOrder.cs
- TypeValidationEventArgs.cs
- StylusButtonCollection.cs
- DescriptionAttribute.cs
- DataTableExtensions.cs
- HttpCacheVary.cs
- TextChange.cs
- ErrorInfoXmlDocument.cs
- WebPartZoneBaseDesigner.cs
- WebPartExportVerb.cs
- LogLogRecordHeader.cs
- DbReferenceCollection.cs
- ObjectDataSourceStatusEventArgs.cs
- SByte.cs
- TypeDescriptor.cs
- COM2FontConverter.cs
- Path.cs
- basevalidator.cs
- ObjectFactoryCodeDomTreeGenerator.cs
- ColumnHeaderConverter.cs
- WebPartEditorCancelVerb.cs
- IntSecurity.cs
- ObservableCollection.cs
- ObjectListItem.cs
- HtmlControl.cs
- _NTAuthentication.cs
- BitmapEffectInput.cs
- Grid.cs
- CLSCompliantAttribute.cs
- AdornerLayer.cs
- AstTree.cs
- MsmqIntegrationOutputChannel.cs
- JoinElimination.cs
- MarkedHighlightComponent.cs
- CompilerParameters.cs
- ToolTipAutomationPeer.cs
- CollectionViewGroup.cs
- PassportAuthenticationEventArgs.cs
- CallSiteOps.cs
- DataPagerFieldCommandEventArgs.cs
- StickyNoteAnnotations.cs
- XmlSchemaInfo.cs
- TemplateXamlParser.cs
- XmlNamespaceDeclarationsAttribute.cs
- GC.cs
- diagnosticsswitches.cs
- RawMouseInputReport.cs
- NestedContainer.cs
- XmlCountingReader.cs
- CompositeActivityDesigner.cs
- Utility.cs
- IpcPort.cs
- FormsAuthentication.cs
- CloseCryptoHandleRequest.cs
- SecurityContext.cs
- Cursors.cs
- MultiPageTextView.cs
- MemberHolder.cs
- VScrollProperties.cs