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
- SqlMetaData.cs
- Vector3DIndependentAnimationStorage.cs
- ImageButton.cs
- LocalizationParserHooks.cs
- TransformProviderWrapper.cs
- ArrayWithOffset.cs
- MessageSmuggler.cs
- OperandQuery.cs
- ModelVisual3D.cs
- Bezier.cs
- SHA384.cs
- ComEventsInfo.cs
- AuthenticodeSignatureInformation.cs
- DecimalStorage.cs
- RoleManagerSection.cs
- TaiwanLunisolarCalendar.cs
- WeakReadOnlyCollection.cs
- LowerCaseStringConverter.cs
- EnumValidator.cs
- NetCodeGroup.cs
- EntityCommandCompilationException.cs
- XmlDocumentType.cs
- Int32Converter.cs
- DataGridCommandEventArgs.cs
- BaseProcessor.cs
- InOutArgument.cs
- MultilineStringConverter.cs
- KnownTypeAttribute.cs
- PolyQuadraticBezierSegment.cs
- EntityDesignerBuildProvider.cs
- ExceptionUtil.cs
- ActivityInterfaces.cs
- DataKeyPropertyAttribute.cs
- PolyLineSegment.cs
- EntityTransaction.cs
- SqlVisitor.cs
- Baml2006KnownTypes.cs
- ControlParameter.cs
- TextContainerChangedEventArgs.cs
- TypeDescriptionProvider.cs
- _BaseOverlappedAsyncResult.cs
- SqlExpressionNullability.cs
- GridPatternIdentifiers.cs
- BamlCollectionHolder.cs
- DataGridViewCheckBoxCell.cs
- AmbientProperties.cs
- GridViewSortEventArgs.cs
- EdmRelationshipRoleAttribute.cs
- Unit.cs
- ByteRangeDownloader.cs
- KeyPressEvent.cs
- SafeEventLogReadHandle.cs
- GenericsNotImplementedException.cs
- TextRangeEditLists.cs
- AmbientProperties.cs
- HttpException.cs
- Pens.cs
- SystemResourceHost.cs
- UriParserTemplates.cs
- MgmtConfigurationRecord.cs
- PerfCounters.cs
- TreeNodeStyleCollection.cs
- ExceptionUtil.cs
- VideoDrawing.cs
- WindowsToolbar.cs
- SiteMapNodeItem.cs
- PatternMatchRules.cs
- XmlNodeList.cs
- UnaryNode.cs
- SizeAnimation.cs
- TextProperties.cs
- PropertyChangedEventArgs.cs
- DataGridViewComboBoxColumnDesigner.cs
- RequestTimeoutManager.cs
- EditorPart.cs
- MailWebEventProvider.cs
- SpeechRecognizer.cs
- PermissionRequestEvidence.cs
- ConstraintManager.cs
- XPathScanner.cs
- WindowsRebar.cs
- TypeForwardedToAttribute.cs
- DataGridDetailsPresenterAutomationPeer.cs
- StatusBarPanel.cs
- Rect3D.cs
- OpCodes.cs
- precedingquery.cs
- OleDbTransaction.cs
- ProviderManager.cs
- DateBoldEvent.cs
- FontFamily.cs
- DataSourceSelectArguments.cs
- OSEnvironmentHelper.cs
- StringReader.cs
- RowToParametersTransformer.cs
- SQLByte.cs
- ValueUnavailableException.cs
- VisualBasicDesignerHelper.cs
- ChangeNode.cs
- ScriptResourceHandler.cs