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
- TagPrefixCollection.cs
- ParseElementCollection.cs
- HttpGetServerProtocol.cs
- ClientScriptManager.cs
- ReflectionTypeLoadException.cs
- ProxyWebPartConnectionCollection.cs
- SmiContextFactory.cs
- PointLightBase.cs
- EmptyElement.cs
- SqlBuilder.cs
- SimpleHandlerFactory.cs
- AssemblyAttributesGoHere.cs
- Atom10FormatterFactory.cs
- SQLMembershipProvider.cs
- followingquery.cs
- FactoryRecord.cs
- FileDetails.cs
- ProgressBarHighlightConverter.cs
- baseshape.cs
- ViewLoader.cs
- WorkflowMarkupSerializationException.cs
- JsonClassDataContract.cs
- PreDigestedSignedInfo.cs
- NullableLongMinMaxAggregationOperator.cs
- OutOfMemoryException.cs
- IDQuery.cs
- AnnotationAuthorChangedEventArgs.cs
- MonikerProxyAttribute.cs
- EventLogLink.cs
- DataGridViewDesigner.cs
- GlobalItem.cs
- ManagementObjectCollection.cs
- ZoomPercentageConverter.cs
- ListView.cs
- NativeObjectSecurity.cs
- CodeBlockBuilder.cs
- CompensationHandlingFilter.cs
- ObjectAnimationUsingKeyFrames.cs
- ArraySegment.cs
- HuffCodec.cs
- BackStopAuthenticationModule.cs
- PerformanceCounterManager.cs
- SqlDataSourceConfigureSelectPanel.cs
- SoapConverter.cs
- DataGridViewImageColumn.cs
- ControlIdConverter.cs
- ConstructorArgumentAttribute.cs
- HtmlPhoneCallAdapter.cs
- FileStream.cs
- Interlocked.cs
- ConnectionsZone.cs
- UnauthorizedWebPart.cs
- ClassHandlersStore.cs
- TextBoxAutoCompleteSourceConverter.cs
- ToolStripScrollButton.cs
- StdValidatorsAndConverters.cs
- ReachFixedPageSerializerAsync.cs
- WindowExtensionMethods.cs
- SystemResourceKey.cs
- RecognizedWordUnit.cs
- IdentitySection.cs
- EntryPointNotFoundException.cs
- CodeMemberField.cs
- RsaSecurityToken.cs
- RelOps.cs
- ApplicationBuildProvider.cs
- AttributeCollection.cs
- SQLGuid.cs
- LockedActivityGlyph.cs
- CodeDirectoryCompiler.cs
- DrawingContext.cs
- Set.cs
- SqlGenericUtil.cs
- FixedPageAutomationPeer.cs
- dataSvcMapFileLoader.cs
- AtomServiceDocumentSerializer.cs
- ComboBoxHelper.cs
- DataGridViewRowEventArgs.cs
- Logging.cs
- StringFormat.cs
- RightsManagementEncryptionTransform.cs
- Pointer.cs
- CatchBlock.cs
- NativeMethods.cs
- PropertySourceInfo.cs
- SocketAddress.cs
- PathFigureCollection.cs
- TypeDelegator.cs
- SqlSupersetValidator.cs
- HttpModuleCollection.cs
- BrowserInteropHelper.cs
- HierarchicalDataTemplate.cs
- Table.cs
- SqlStream.cs
- ServerValidateEventArgs.cs
- BufferModesCollection.cs
- FixedSOMTable.cs
- StringPropertyBuilder.cs
- HttpRawResponse.cs
- DbResourceAllocator.cs