Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / System.Runtime.DurableInstancing / System / Runtime / Interop / SafeEventLogWriteHandle.cs / 1305376 / SafeEventLogWriteHandle.cs
//------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------- namespace System.Runtime.Interop { using Microsoft.Win32.SafeHandles; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Globalization; using System.Diagnostics; using System.Security; [Fx.Tag.SecurityNote(Critical = "Usage of SafeHandleZeroOrMinusOneIsInvalid, which is protected by a LinkDemand and InheritanceDemand")] [SecurityCritical] sealed class SafeEventLogWriteHandle : SafeHandleZeroOrMinusOneIsInvalid { // Note: RegisterEventSource returns 0 on failure [Fx.Tag.SecurityNote(Critical = "Usage of SafeHandleZeroOrMinusOneIsInvalid, which is protected by a LinkDemand and InheritanceDemand")] [SecurityCritical] SafeEventLogWriteHandle() : base(true) { } [ResourceConsumption(ResourceScope.Machine)] [Fx.Tag.SecurityNote(Critical = "Usage of SafeHandleZeroOrMinusOneIsInvalid, which is protected by a LinkDemand and InheritanceDemand")] [SecurityCritical] public static SafeEventLogWriteHandle RegisterEventSource(string uncServerName, string sourceName) { SafeEventLogWriteHandle retval = UnsafeNativeMethods.RegisterEventSource(uncServerName, sourceName); int error = Marshal.GetLastWin32Error(); if (retval.IsInvalid) { Debug.Print("SafeEventLogWriteHandle::RegisterEventSource[" + uncServerName + ", " + sourceName + "] Failed. Last Error: " + error.ToString(CultureInfo.InvariantCulture)); } return retval; } [DllImport("advapi32", SetLastError = true)] [ResourceExposure(ResourceScope.None)] static extern bool DeregisterEventSource(IntPtr hEventLog); [Fx.Tag.SecurityNote(Critical = "Usage of SafeHandleZeroOrMinusOneIsInvalid, which is protected by a LinkDemand and InheritanceDemand")] [SecurityCritical] protected override bool ReleaseHandle() { return DeregisterEventSource(this.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
- wmiprovider.cs
- Oid.cs
- _LoggingObject.cs
- EngineSiteSapi.cs
- CurrencyManager.cs
- SymbolType.cs
- CustomWebEventKey.cs
- ModuleBuilderData.cs
- Parallel.cs
- sqlnorm.cs
- CodePageUtils.cs
- SimpleRecyclingCache.cs
- CodeCatchClauseCollection.cs
- SqlWebEventProvider.cs
- DialogBaseForm.cs
- RequestCacheEntry.cs
- DataObjectEventArgs.cs
- AssemblyUtil.cs
- Native.cs
- OdbcErrorCollection.cs
- ManagedFilter.cs
- ValidationSummary.cs
- NamespaceCollection.cs
- MsmqInputChannel.cs
- UnaryOperationBinder.cs
- ResolveNameEventArgs.cs
- ParentQuery.cs
- WinEventHandler.cs
- XmlEntity.cs
- CallContext.cs
- X509WindowsSecurityToken.cs
- ZipIOEndOfCentralDirectoryBlock.cs
- RuntimeConfig.cs
- RemoteWebConfigurationHostServer.cs
- AsyncResult.cs
- RenderCapability.cs
- ExtendLockAsyncResult.cs
- IPEndPoint.cs
- HttpListener.cs
- DataGridViewCellConverter.cs
- TextServicesProperty.cs
- CharEnumerator.cs
- XsltOutput.cs
- ImageFormatConverter.cs
- Atom10FormatterFactory.cs
- QilTernary.cs
- AlternateView.cs
- ArrayList.cs
- Calendar.cs
- NavigationPropertyEmitter.cs
- DependencyPropertyHelper.cs
- Schema.cs
- Line.cs
- FacetDescription.cs
- SiteMapNodeItemEventArgs.cs
- LOSFormatter.cs
- XmlCountingReader.cs
- TypeDescriptor.cs
- GlobalProxySelection.cs
- CriticalFinalizerObject.cs
- SingleConverter.cs
- ImageCodecInfo.cs
- CapiHashAlgorithm.cs
- BindingNavigator.cs
- sqlpipe.cs
- SqlServer2KCompatibilityAnnotation.cs
- InputLangChangeEvent.cs
- SpellerStatusTable.cs
- RouteParametersHelper.cs
- QueryExtender.cs
- InlinedAggregationOperatorEnumerator.cs
- SelectionListDesigner.cs
- SelectionRangeConverter.cs
- PackageRelationshipSelector.cs
- PersonalizationProvider.cs
- DataGridViewDesigner.cs
- MsmqBindingElementBase.cs
- TextDocumentView.cs
- GrammarBuilderDictation.cs
- SpecialNameAttribute.cs
- SqlDataSourceConfigureSelectPanel.cs
- ReverseQueryOperator.cs
- ArithmeticException.cs
- GraphicsState.cs
- WebResourceAttribute.cs
- documentsequencetextview.cs
- GACMembershipCondition.cs
- UserControlCodeDomTreeGenerator.cs
- SessionStateItemCollection.cs
- SafeEventLogWriteHandle.cs
- CommandLibraryHelper.cs
- ExceptionHelpers.cs
- ThumbAutomationPeer.cs
- PagesChangedEventArgs.cs
- Helper.cs
- ObjectDataSourceDesigner.cs
- ResizeGrip.cs
- AnimationTimeline.cs
- HtmlInputButton.cs
- SqlInternalConnection.cs