Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / Tools / xws_reg / System / ServiceModel / Install / ServiceManagerHandle.cs / 1 / ServiceManagerHandle.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.ServiceModel.Install { using Microsoft.Win32.SafeHandles; using System; using System.ComponentModel; using System.Diagnostics; using System.Runtime.ConstrainedExecution; using System.Runtime.InteropServices; using System.Security.AccessControl; using System.Text; internal class ServiceManagerHandle : SafeHandleZeroOrMinusOneIsInvalid { internal ServiceManagerHandle() : base(true) { } internal ServiceHandle CreateService(string serviceName, string displayName, int serviceType, int startType, int errorControl, string binaryPathName, string dependencies, string serviceStartName) { const int desiredAccess = NativeMethods.SERVICE_CHANGE_CONFIG | // setting the description NativeMethods.SERVICE_START | // setting the failure actions NativeMethods.WRITE_DAC | // setting the DACL NativeMethods.ACCESS_SYSTEM_SECURITY; // setting the SACL #pragma warning suppress 56523 // [....]; Win32Exception default constructor calls Marshal.GetLastWin32Error() internally. ServiceHandle retVal = NativeMethods.CreateService(this, serviceName, displayName, desiredAccess, serviceType, startType, errorControl, binaryPathName, null, IntPtr.Zero, dependencies, serviceStartName, null); if ((retVal == null) || retVal.IsInvalid) { throw new Win32Exception(); } return retVal; } internal ServiceHandle OpenService(string serviceName, int desiredAccess) { #pragma warning suppress 56523 // [....]; Win32Exception default constructor calls Marshal.GetLastWin32Error() internally. ServiceHandle retVal = NativeMethods.OpenService(this, serviceName, desiredAccess); if ((null == retVal) || retVal.IsInvalid) { throw new Win32Exception(); } return retVal; } internal static ServiceManagerHandle OpenServiceManager() { #pragma warning suppress 56523 // [....]; Win32Exception default constructor calls Marshal.GetLastWin32Error() internally. ServiceManagerHandle retVal = NativeMethods.OpenSCManager(null, null, NativeMethods.SC_MANAGER_ALL_ACCESS); if ((null == retVal) || retVal.IsInvalid) { throw new Win32Exception(); } return retVal; } protected override bool ReleaseHandle() { #pragma warning suppress 56523 // [....]; Win32Exception default constructor calls Marshal.GetLastWin32Error() internally. bool retVal = NativeMethods.CloseServiceHandle(handle); if (!retVal) { throw new Win32Exception(); } return retVal; } } } // 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
- Hashtable.cs
- TextBlock.cs
- JsonReader.cs
- StringTraceRecord.cs
- UserPreferenceChangedEventArgs.cs
- ZipIOLocalFileBlock.cs
- ToolStripArrowRenderEventArgs.cs
- AdjustableArrowCap.cs
- ImmutableObjectAttribute.cs
- SelectedPathEditor.cs
- GridPattern.cs
- Popup.cs
- IconHelper.cs
- ToolboxItemAttribute.cs
- WebPartMenuStyle.cs
- BackStopAuthenticationModule.cs
- login.cs
- SecurityContext.cs
- XmlNodeList.cs
- DrawingGroup.cs
- ExtentKey.cs
- Process.cs
- DataProtection.cs
- XmlToDatasetMap.cs
- TemplateBindingExpression.cs
- AssemblyCollection.cs
- VirtualizingStackPanel.cs
- ToolStripTextBox.cs
- ResolvedKeyFrameEntry.cs
- QilInvoke.cs
- WindowsStartMenu.cs
- ToolStripRendererSwitcher.cs
- ToolStripGripRenderEventArgs.cs
- NetTcpSectionData.cs
- DesignerDataConnection.cs
- PathSegment.cs
- DataGridViewColumn.cs
- MarkedHighlightComponent.cs
- LineInfo.cs
- HostingPreferredMapPath.cs
- EntityDataSourceMemberPath.cs
- VarRefManager.cs
- Durable.cs
- XmlArrayItemAttribute.cs
- ToolStripRenderEventArgs.cs
- TypeBuilderInstantiation.cs
- EnumDataContract.cs
- CFGGrammar.cs
- FontWeightConverter.cs
- FormParameter.cs
- EntityDataSourceChangedEventArgs.cs
- PolyLineSegment.cs
- CurrentTimeZone.cs
- TextSelectionHelper.cs
- Array.cs
- AvtEvent.cs
- autovalidator.cs
- ApplicationDirectory.cs
- TranslateTransform3D.cs
- StaticResourceExtension.cs
- NumericUpDownAcceleration.cs
- HTMLTextWriter.cs
- MetafileHeader.cs
- XmlTypeAttribute.cs
- ProtocolsConfigurationEntry.cs
- DocumentReference.cs
- WriterOutput.cs
- ProviderIncompatibleException.cs
- Clipboard.cs
- ActivationArguments.cs
- OrthographicCamera.cs
- SelectionProcessor.cs
- OleDbSchemaGuid.cs
- ZoneButton.cs
- TextBoxRenderer.cs
- MatrixIndependentAnimationStorage.cs
- SerTrace.cs
- _NegotiateClient.cs
- JournalEntryStack.cs
- controlskin.cs
- ReflectionServiceProvider.cs
- StringDictionaryCodeDomSerializer.cs
- IERequestCache.cs
- BindingsCollection.cs
- Context.cs
- ReverseQueryOperator.cs
- SyntaxCheck.cs
- OutputCacheProfileCollection.cs
- DispatcherHookEventArgs.cs
- SqlExpressionNullability.cs
- EmissiveMaterial.cs
- ProgressBar.cs
- RtfToken.cs
- FtpWebRequest.cs
- ChannelManager.cs
- ChangeTracker.cs
- EdmRelationshipRoleAttribute.cs
- DictionarySectionHandler.cs
- DynamicVirtualDiscoSearcher.cs
- EventDriven.cs