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
- _AuthenticationState.cs
- _Win32.cs
- TdsEnums.cs
- DefaultExpression.cs
- SamlAssertionDirectKeyIdentifierClause.cs
- PerformanceCountersElement.cs
- DataBoundControlHelper.cs
- TransportContext.cs
- PathData.cs
- HebrewCalendar.cs
- FormViewModeEventArgs.cs
- LinearKeyFrames.cs
- WindowsStreamSecurityUpgradeProvider.cs
- ClientRuntimeConfig.cs
- SqlTransaction.cs
- FixedSOMContainer.cs
- SqlConnectionString.cs
- JoinElimination.cs
- MenuCommands.cs
- IndexedGlyphRun.cs
- Operand.cs
- TextBox.cs
- GregorianCalendar.cs
- AudioDeviceOut.cs
- SqlDataSourceView.cs
- ListManagerBindingsCollection.cs
- SplitContainer.cs
- KeyValueConfigurationCollection.cs
- MobileTextWriter.cs
- DBSchemaRow.cs
- ClassValidator.cs
- WmfPlaceableFileHeader.cs
- TdsParserHelperClasses.cs
- TimelineClockCollection.cs
- DynamicDiscoveryDocument.cs
- AnimationLayer.cs
- DataGridViewCellParsingEventArgs.cs
- XmlResolver.cs
- Tuple.cs
- Focus.cs
- DynamicRouteExpression.cs
- ProvidersHelper.cs
- PrinterSettings.cs
- XmlAtomicValue.cs
- UnsafeCollabNativeMethods.cs
- SemanticResultKey.cs
- SynchronizedDisposablePool.cs
- ProcessHostMapPath.cs
- XmlBindingWorker.cs
- BuildResult.cs
- XmlLinkedNode.cs
- input.cs
- UserMapPath.cs
- DataGridViewCellStyleEditor.cs
- ConfigXmlSignificantWhitespace.cs
- Int32AnimationBase.cs
- URLBuilder.cs
- sqlmetadatafactory.cs
- NotEqual.cs
- HostedHttpRequestAsyncResult.cs
- ByteStorage.cs
- BindingExpressionUncommonField.cs
- AssemblyBuilder.cs
- Model3DCollection.cs
- RawStylusInputCustomDataList.cs
- DataGridViewColumnEventArgs.cs
- UInt32Storage.cs
- MimeBasePart.cs
- Enum.cs
- ValuePattern.cs
- IdentityReference.cs
- TextSelection.cs
- IntegrationExceptionEventArgs.cs
- XmlTextReader.cs
- CanonicalizationDriver.cs
- SiteMapPath.cs
- RelationshipEndCollection.cs
- PreApplicationStartMethodAttribute.cs
- ErrorLog.cs
- DocumentViewer.cs
- GuidConverter.cs
- SafeRightsManagementPubHandle.cs
- LogExtent.cs
- SqlProviderManifest.cs
- CellLabel.cs
- FormDesigner.cs
- SizeConverter.cs
- TableStyle.cs
- TreeNodeStyleCollectionEditor.cs
- BrowserCapabilitiesFactory.cs
- GridViewDeleteEventArgs.cs
- CompilerWrapper.cs
- StrokeIntersection.cs
- mansign.cs
- SettingsBindableAttribute.cs
- Base64Encoding.cs
- BamlBinaryWriter.cs
- SqlCommand.cs
- CodeCompiler.cs
- EventMap.cs