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
- Properties.cs
- ActivityStatusChangeEventArgs.cs
- PersonalizationProviderHelper.cs
- _CookieModule.cs
- UIElement3DAutomationPeer.cs
- SizeChangedEventArgs.cs
- DirectionalLight.cs
- LinearGradientBrush.cs
- Overlapped.cs
- DBConcurrencyException.cs
- XamlSerializationHelper.cs
- XmlSchemaAppInfo.cs
- CodeDomConfigurationHandler.cs
- BrushConverter.cs
- ConnectAlgorithms.cs
- FieldToken.cs
- DocobjHost.cs
- ProxyHwnd.cs
- ThemeableAttribute.cs
- RoleGroupCollectionEditor.cs
- AttributeData.cs
- RequestNavigateEventArgs.cs
- BlobPersonalizationState.cs
- DesignerCommandAdapter.cs
- EmbeddedMailObjectsCollection.cs
- QuotedPrintableStream.cs
- PolicyLevel.cs
- MessageEnumerator.cs
- TextElementEditingBehaviorAttribute.cs
- SqlBinder.cs
- DataControlField.cs
- XmlSchemaInfo.cs
- ServiceModelExtensionCollectionElement.cs
- Double.cs
- SafeThreadHandle.cs
- CallSiteHelpers.cs
- Int32AnimationUsingKeyFrames.cs
- BaseCodeDomTreeGenerator.cs
- DataGridViewCellStyleEditor.cs
- SelectorItemAutomationPeer.cs
- FixedStringLookup.cs
- Matrix.cs
- SqlEnums.cs
- RefreshPropertiesAttribute.cs
- PromptEventArgs.cs
- PageParserFilter.cs
- UserControlFileEditor.cs
- HtmlHead.cs
- FrameworkElementAutomationPeer.cs
- RuntimeResourceSet.cs
- DoubleLinkListEnumerator.cs
- BamlBinaryReader.cs
- SmtpTransport.cs
- InstanceDescriptor.cs
- EnumValidator.cs
- InputLanguageSource.cs
- ConfigXmlComment.cs
- PeerNameRecord.cs
- _IPv6Address.cs
- HitTestDrawingContextWalker.cs
- XmlTextAttribute.cs
- SecurityException.cs
- TryCatchDesigner.xaml.cs
- ObjectDataSourceFilteringEventArgs.cs
- BindingSource.cs
- AutoResetEvent.cs
- UDPClient.cs
- SqlUserDefinedTypeAttribute.cs
- DataRowCollection.cs
- GregorianCalendarHelper.cs
- ActivityTypeResolver.xaml.cs
- VerificationAttribute.cs
- InputReferenceExpression.cs
- RewritingValidator.cs
- FontStyles.cs
- UdpChannelListener.cs
- FormatControl.cs
- Main.cs
- CharAnimationUsingKeyFrames.cs
- HitTestWithGeometryDrawingContextWalker.cs
- WizardForm.cs
- EncoderNLS.cs
- MailMessageEventArgs.cs
- IISMapPath.cs
- PropertyChangedEventManager.cs
- WebBrowserSiteBase.cs
- UrlMappingsModule.cs
- XsltException.cs
- SpeechDetectedEventArgs.cs
- TcpHostedTransportConfiguration.cs
- ErrorHandler.cs
- SQLConvert.cs
- ListItemConverter.cs
- ReaderWriterLock.cs
- TreeNodeStyleCollection.cs
- LinkDescriptor.cs
- OrderedDictionary.cs
- SaveWorkflowAsyncResult.cs
- CompoundFileReference.cs
- WebEventCodes.cs