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
- SpellerError.cs
- GenericQueueSurrogate.cs
- DataGridLengthConverter.cs
- QueryValue.cs
- DropDownButton.cs
- ContainerSelectorActiveEvent.cs
- ToolStripSystemRenderer.cs
- AddInControllerImpl.cs
- SemanticKeyElement.cs
- ScriptResourceAttribute.cs
- WebPartTransformerCollection.cs
- SubMenuStyleCollection.cs
- SourceElementsCollection.cs
- DefaultWorkflowSchedulerService.cs
- AxHost.cs
- TextReader.cs
- activationcontext.cs
- StringCollection.cs
- ClientApiGenerator.cs
- SubclassTypeValidatorAttribute.cs
- HtmlGenericControl.cs
- ContainerUIElement3D.cs
- IndexerNameAttribute.cs
- Popup.cs
- ContextMenuAutomationPeer.cs
- AssemblyCollection.cs
- HScrollBar.cs
- PointUtil.cs
- ParagraphVisual.cs
- Rfc2898DeriveBytes.cs
- Parameter.cs
- BoolLiteral.cs
- XmlParserContext.cs
- StrongNameMembershipCondition.cs
- TreeViewAutomationPeer.cs
- SpotLight.cs
- StateBag.cs
- AppModelKnownContentFactory.cs
- RelationshipConstraintValidator.cs
- SizeLimitedCache.cs
- TraceContextRecord.cs
- OrderingExpression.cs
- Queue.cs
- WindowsAuthenticationModule.cs
- Condition.cs
- SiteMapSection.cs
- PasswordBoxAutomationPeer.cs
- ProfileService.cs
- TargetInvocationException.cs
- Context.cs
- RedirectionProxy.cs
- AddDataControlFieldDialog.cs
- BamlRecordReader.cs
- XsdDateTime.cs
- EntityDataSourceSelectedEventArgs.cs
- TemplateAction.cs
- DocumentsTrace.cs
- EmptyControlCollection.cs
- MaterialGroup.cs
- Update.cs
- Image.cs
- AdapterDictionary.cs
- AdjustableArrowCap.cs
- ImpersonationContext.cs
- ToolboxItemCollection.cs
- KeyboardDevice.cs
- BaseAddressPrefixFilterElement.cs
- CalendarTable.cs
- IndentedWriter.cs
- RegexStringValidatorAttribute.cs
- RectConverter.cs
- ResXResourceWriter.cs
- TextParagraphView.cs
- DataColumnCollection.cs
- XmlValueConverter.cs
- XmlSchemaSimpleTypeRestriction.cs
- SmtpLoginAuthenticationModule.cs
- parserscommon.cs
- TextComposition.cs
- xsdvalidator.cs
- WsatAdminException.cs
- DiscoveryProxy.cs
- GlobalizationAssembly.cs
- WebScriptClientGenerator.cs
- CodePrimitiveExpression.cs
- DataSet.cs
- LambdaCompiler.ControlFlow.cs
- CaseExpr.cs
- SoapElementAttribute.cs
- TypeCodeDomSerializer.cs
- TreeNodeEventArgs.cs
- ActivityBindForm.cs
- TextElementAutomationPeer.cs
- EntityClassGenerator.cs
- RtfNavigator.cs
- ErrorHandler.cs
- AppSettingsSection.cs
- DataRelationPropertyDescriptor.cs
- ConcatQueryOperator.cs
- SignatureDescription.cs