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
- SafeHandle.cs
- AudioException.cs
- Int32Rect.cs
- localization.cs
- DataGridViewSelectedColumnCollection.cs
- ISCIIEncoding.cs
- ResourcesChangeInfo.cs
- AppSettingsReader.cs
- FramingChannels.cs
- OutputCacheSettingsSection.cs
- EncodingFallbackAwareXmlTextWriter.cs
- NamespaceCollection.cs
- EntityDataSourceWrapper.cs
- BufferedGraphicsContext.cs
- SqlTypeConverter.cs
- CryptoApi.cs
- MetadataItem.cs
- PeerFlooder.cs
- _Win32.cs
- PaginationProgressEventArgs.cs
- TableItemStyle.cs
- AvTrace.cs
- BufferedReadStream.cs
- TabItemAutomationPeer.cs
- ExtractedStateEntry.cs
- ServerValidateEventArgs.cs
- Operators.cs
- ComboBoxAutomationPeer.cs
- SHA384Cng.cs
- AnimationException.cs
- ListChangedEventArgs.cs
- InternalResources.cs
- SvcFileManager.cs
- GeneralTransformGroup.cs
- DbFunctionCommandTree.cs
- DateTimeSerializationSection.cs
- DynamicValidator.cs
- HtmlEmptyTagControlBuilder.cs
- PolyBezierSegment.cs
- DesignTimeResourceProviderFactoryAttribute.cs
- HostExecutionContextManager.cs
- Int32RectValueSerializer.cs
- FormViewRow.cs
- GuidConverter.cs
- WindowsIPAddress.cs
- OdbcException.cs
- UserNameSecurityTokenAuthenticator.cs
- SessionStateSection.cs
- ManipulationDeltaEventArgs.cs
- newitemfactory.cs
- MatchingStyle.cs
- ProcessModelSection.cs
- ServiceManager.cs
- HttpsTransportElement.cs
- Context.cs
- Attribute.cs
- Point4D.cs
- RowUpdatingEventArgs.cs
- SQLBytes.cs
- StatusStrip.cs
- XmlSchemaProviderAttribute.cs
- UpdateException.cs
- DivideByZeroException.cs
- StringUtil.cs
- RenderOptions.cs
- MetaData.cs
- BatchServiceHost.cs
- CodePageEncoding.cs
- DataGridViewCellFormattingEventArgs.cs
- AffineTransform3D.cs
- DataGrid.cs
- LineGeometry.cs
- StringKeyFrameCollection.cs
- Validator.cs
- DataObjectCopyingEventArgs.cs
- FontFamilyValueSerializer.cs
- ToolZone.cs
- SqlResolver.cs
- ToolStripSplitStackLayout.cs
- WindowsHyperlink.cs
- ButtonFieldBase.cs
- SrgsNameValueTag.cs
- ObjectDataSourceFilteringEventArgs.cs
- Token.cs
- FileDataSource.cs
- XmlSortKey.cs
- StreamInfo.cs
- ReceiveSecurityHeaderEntry.cs
- BitmapEffectDrawingContextState.cs
- EntityModelSchemaGenerator.cs
- basecomparevalidator.cs
- HttpHandlersSection.cs
- FormParameter.cs
- XmlDictionary.cs
- MetadataProperty.cs
- DispatchWrapper.cs
- ChangePassword.cs
- HotSpot.cs
- DesignerDataStoredProcedure.cs
- FunctionQuery.cs