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
- WebPartConnectVerb.cs
- FlowDocumentReader.cs
- Nullable.cs
- SchemaImporterExtension.cs
- DataListGeneralPage.cs
- HtmlContainerControl.cs
- ObjectDataSourceView.cs
- TrackingProfile.cs
- CodeArgumentReferenceExpression.cs
- StringConverter.cs
- ExtenderProvidedPropertyAttribute.cs
- IndexObject.cs
- UriParserTemplates.cs
- DropTarget.cs
- DataPager.cs
- DistributedTransactionPermission.cs
- RegionInfo.cs
- WebPartExportVerb.cs
- DataRecordObjectView.cs
- CodeDOMUtility.cs
- ConfigXmlAttribute.cs
- EventPrivateKey.cs
- RoleService.cs
- DbProviderConfigurationHandler.cs
- FrameSecurityDescriptor.cs
- NamedObject.cs
- TypeReference.cs
- GeneralTransform3DGroup.cs
- HMACMD5.cs
- IgnoreDeviceFilterElementCollection.cs
- DebugView.cs
- ActivationService.cs
- SqlDataSource.cs
- Span.cs
- FileDialog_Vista.cs
- DispatcherSynchronizationContext.cs
- RightsManagementInformation.cs
- DataContractJsonSerializerOperationFormatter.cs
- InputReportEventArgs.cs
- VectorKeyFrameCollection.cs
- DocumentPage.cs
- ChildChangedEventArgs.cs
- WindowsTitleBar.cs
- SelectionHighlightInfo.cs
- AnimatedTypeHelpers.cs
- ReadOnlyCollectionBase.cs
- Html32TextWriter.cs
- DataGridViewAccessibleObject.cs
- PasswordBoxAutomationPeer.cs
- BypassElement.cs
- XmlQueryOutput.cs
- DesignerAutoFormat.cs
- MetafileHeaderWmf.cs
- WSDualHttpSecurityMode.cs
- SqlFormatter.cs
- HealthMonitoringSection.cs
- DataGridView.cs
- QuinticEase.cs
- DataSourceDescriptorCollection.cs
- TableRow.cs
- Scene3D.cs
- TextTreeText.cs
- ProviderConnectionPoint.cs
- PerformanceCounterPermissionAttribute.cs
- SeekableReadStream.cs
- ApplicationHost.cs
- SecurityDescriptor.cs
- Cursor.cs
- CheckBoxList.cs
- unitconverter.cs
- SchemaMapping.cs
- AssertFilter.cs
- IMembershipProvider.cs
- Part.cs
- SerializerWriterEventHandlers.cs
- Transactions.cs
- EmptyReadOnlyDictionaryInternal.cs
- ColumnReorderedEventArgs.cs
- TransformCryptoHandle.cs
- LinqTreeNodeEvaluator.cs
- CryptoApi.cs
- FloaterBaseParagraph.cs
- SoapExtension.cs
- XmlElementList.cs
- MatrixValueSerializer.cs
- VersionUtil.cs
- ColumnBinding.cs
- MessageBox.cs
- AuthorizationRule.cs
- TitleStyle.cs
- NavigationWindow.cs
- CookieProtection.cs
- SystemTcpConnection.cs
- GroupStyle.cs
- AuthenticateEventArgs.cs
- DependencyPropertyAttribute.cs
- ConfigXmlDocument.cs
- ConfigurationManagerInternal.cs
- Base64Stream.cs
- DataGridViewSelectedCellsAccessibleObject.cs