Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / SMDiagnostics / System / ServiceModel / Diagnostics / SafeEventLogWriteHandle.cs / 1 / SafeEventLogWriteHandle.cs
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------
namespace System.ServiceModel.Diagnostics
{
using Microsoft.Win32.SafeHandles;
using System.Runtime.InteropServices;
using System.Globalization;
using System.Diagnostics;
internal sealed class SafeEventLogWriteHandle : SafeHandleZeroOrMinusOneIsInvalid
{
// Note: RegisterEventSource returns 0 on failure
SafeEventLogWriteHandle() : base(true) { }
internal static SafeEventLogWriteHandle RegisterEventSource(string uncServerName, string sourceName)
{
SafeEventLogWriteHandle retval = NativeMethods.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)]
private static extern bool DeregisterEventSource(IntPtr hEventLog);
#pragma warning disable 56523
override protected bool ReleaseHandle()
{
return DeregisterEventSource(this.handle);
}
#pragma warning restore 56523
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- Function.cs
- PreProcessor.cs
- WebPartDeleteVerb.cs
- followingquery.cs
- UserNamePasswordValidator.cs
- MethodBuilder.cs
- HtmlMobileTextWriter.cs
- TerminatorSinks.cs
- DependencyPropertyHelper.cs
- KnownTypesProvider.cs
- OracleColumn.cs
- GenericXmlSecurityToken.cs
- BufferedGenericXmlSecurityToken.cs
- Geometry.cs
- CopyCodeAction.cs
- Container.cs
- TextTreeInsertElementUndoUnit.cs
- PrtTicket_Public.cs
- uribuilder.cs
- SamlAuthorityBinding.cs
- RijndaelManaged.cs
- EncryptedKeyIdentifierClause.cs
- SecurityState.cs
- EntitySqlQueryCacheKey.cs
- WsdlHelpGeneratorElement.cs
- SiteMapNodeItemEventArgs.cs
- TreeNodeBinding.cs
- IdleTimeoutMonitor.cs
- SourceExpressionException.cs
- PeerNameRegistration.cs
- SqlXmlStorage.cs
- TextureBrush.cs
- DesignerTransactionCloseEvent.cs
- DesignerVerbCollection.cs
- SEHException.cs
- StrongNamePublicKeyBlob.cs
- ResourcePool.cs
- IOThreadScheduler.cs
- XmlAutoDetectWriter.cs
- Stackframe.cs
- TextTreeInsertUndoUnit.cs
- RoleService.cs
- ActivityAction.cs
- ValidatorCollection.cs
- GradientStop.cs
- FormViewUpdateEventArgs.cs
- DesignRelation.cs
- RegexNode.cs
- CertificateManager.cs
- ComponentDispatcherThread.cs
- MulticastDelegate.cs
- ZoneButton.cs
- XmlValidatingReaderImpl.cs
- RoleBoolean.cs
- SQLDouble.cs
- SerializationEventsCache.cs
- BooleanToVisibilityConverter.cs
- BitmapSizeOptions.cs
- handlecollector.cs
- SqlInternalConnection.cs
- DataGridCaption.cs
- NetworkInterface.cs
- StoreContentChangedEventArgs.cs
- CodeRegionDirective.cs
- ProfilePropertySettings.cs
- PrintDocument.cs
- TogglePattern.cs
- System.Data_BID.cs
- ViewService.cs
- EncoderFallback.cs
- CodeSubDirectoriesCollection.cs
- Point4D.cs
- RealProxy.cs
- PiiTraceSource.cs
- InvalidFilterCriteriaException.cs
- LiteralControl.cs
- TraceContextEventArgs.cs
- Visitor.cs
- hwndwrapper.cs
- MatrixTransform3D.cs
- SafeTokenHandle.cs
- PolyBezierSegment.cs
- GenericAuthenticationEventArgs.cs
- UiaCoreProviderApi.cs
- FloaterParaClient.cs
- DocumentAutomationPeer.cs
- ServiceManager.cs
- FrameworkElementFactory.cs
- TableLayoutStyle.cs
- DrawListViewSubItemEventArgs.cs
- handlecollector.cs
- ArraySortHelper.cs
- RootProfilePropertySettingsCollection.cs
- Fx.cs
- WindowsGrip.cs
- TraceUtils.cs
- ImageMapEventArgs.cs
- _Events.cs
- DelegateInArgument.cs
- LinearGradientBrush.cs