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
- AmbientProperties.cs
- DataGridViewCellCollection.cs
- InputLangChangeEvent.cs
- DataGridViewCellFormattingEventArgs.cs
- DataBindingCollection.cs
- Binding.cs
- SettingsPropertyIsReadOnlyException.cs
- ILGenerator.cs
- TokenBasedSetEnumerator.cs
- objectresult_tresulttype.cs
- WeakEventManager.cs
- String.cs
- TimelineClockCollection.cs
- XmlSerializableServices.cs
- TypeTypeConverter.cs
- SynthesizerStateChangedEventArgs.cs
- AdPostCacheSubstitution.cs
- VScrollBar.cs
- RegexCompiler.cs
- ConnectionPointCookie.cs
- UriWriter.cs
- controlskin.cs
- SafeNativeMethods.cs
- FactoryRecord.cs
- GenericsInstances.cs
- UshortList2.cs
- FixUpCollection.cs
- Schema.cs
- DynamicPropertyHolder.cs
- PopOutPanel.cs
- OleDbFactory.cs
- SevenBitStream.cs
- ColumnPropertiesGroup.cs
- XmlMembersMapping.cs
- HostingEnvironment.cs
- DataServiceConfiguration.cs
- ToolStripDropDown.cs
- UIHelper.cs
- IResourceProvider.cs
- CodeCommentStatement.cs
- SplitContainer.cs
- ConnectionString.cs
- SettingsSection.cs
- SqlConnectionManager.cs
- DataGridViewRowPrePaintEventArgs.cs
- SerializationAttributes.cs
- SourceChangedEventArgs.cs
- TableLayoutRowStyleCollection.cs
- Stack.cs
- TrackBarRenderer.cs
- RowVisual.cs
- EditorPartDesigner.cs
- ListItemCollection.cs
- ToolStripPanelDesigner.cs
- WebPartDescriptionCollection.cs
- _CommandStream.cs
- GotoExpression.cs
- WebPartEventArgs.cs
- WebPartHeaderCloseVerb.cs
- DebuggerAttributes.cs
- ReadOnlyDictionary.cs
- WorkflowHostingEndpoint.cs
- DataKeyCollection.cs
- Resources.Designer.cs
- DocumentApplicationState.cs
- EntityAdapter.cs
- transactioncontext.cs
- lengthconverter.cs
- TextDecoration.cs
- COMException.cs
- SQLStringStorage.cs
- FileCodeGroup.cs
- SqlWebEventProvider.cs
- PeerResolverMode.cs
- WorkflowMessageEventArgs.cs
- StringBlob.cs
- AssemblyEvidenceFactory.cs
- HMACSHA1.cs
- ConfigurationStrings.cs
- NotifyParentPropertyAttribute.cs
- Adorner.cs
- SpecularMaterial.cs
- GridViewRowCollection.cs
- DescendantQuery.cs
- CapiSymmetricAlgorithm.cs
- BaseTemplateParser.cs
- UnicastIPAddressInformationCollection.cs
- PermissionSetEnumerator.cs
- FontNamesConverter.cs
- IndicFontClient.cs
- LogicalChannelCollection.cs
- ActivationArguments.cs
- ReadOnlyObservableCollection.cs
- UnlockInstanceAsyncResult.cs
- UnSafeCharBuffer.cs
- SafeTokenHandle.cs
- TraceSection.cs
- Line.cs
- XmlText.cs
- TreeBuilderXamlTranslator.cs