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
- SQLString.cs
- SecurityKeyIdentifier.cs
- VSWCFServiceContractGenerator.cs
- DeleteStoreRequest.cs
- CategoryNameCollection.cs
- DynamicUpdateCommand.cs
- View.cs
- ProfileManager.cs
- RNGCryptoServiceProvider.cs
- ReadOnlyDictionary.cs
- XslCompiledTransform.cs
- TreeNodeConverter.cs
- NonSerializedAttribute.cs
- OrderByBuilder.cs
- TableParagraph.cs
- PointHitTestResult.cs
- InputManager.cs
- ToolboxComponentsCreatedEventArgs.cs
- Decimal.cs
- AssertSection.cs
- RelatedCurrencyManager.cs
- WriteTimeStream.cs
- WebPartUserCapability.cs
- CompositeActivityDesigner.cs
- CompiledQuery.cs
- ConvertersCollection.cs
- MatrixKeyFrameCollection.cs
- EventItfInfo.cs
- EventLogWatcher.cs
- NativeMethodsOther.cs
- DataServices.cs
- EntityDataReader.cs
- xmlfixedPageInfo.cs
- GridView.cs
- HttpResponseHeader.cs
- TextEditorDragDrop.cs
- ReaderWriterLockWrapper.cs
- FixedHyperLink.cs
- SqlResolver.cs
- HeaderCollection.cs
- HttpRawResponse.cs
- HtmlTableCellCollection.cs
- SatelliteContractVersionAttribute.cs
- HtmlTextArea.cs
- LicenseException.cs
- ComponentChangedEvent.cs
- SchemaElementLookUpTableEnumerator.cs
- ImmComposition.cs
- DtdParser.cs
- Cursor.cs
- DataSourceHelper.cs
- ProjectionAnalyzer.cs
- ChannelPoolSettings.cs
- ToolStripDropDownButton.cs
- SchemaLookupTable.cs
- NavigationWindow.cs
- TextParagraphCache.cs
- DebugHandleTracker.cs
- MenuScrollingVisibilityConverter.cs
- WebBrowserDocumentCompletedEventHandler.cs
- OutputCacheSettings.cs
- SurrogateEncoder.cs
- LocatorManager.cs
- StringAttributeCollection.cs
- HttpCachePolicy.cs
- XmlElement.cs
- XmlSchemaComplexContent.cs
- SynchronousReceiveElement.cs
- SmiRecordBuffer.cs
- AuthenticationModulesSection.cs
- TextTreeTextElementNode.cs
- HotSpotCollection.cs
- OpenFileDialog.cs
- Keywords.cs
- ExpressionBindings.cs
- AssemblyAttributesGoHere.cs
- SchemaObjectWriter.cs
- DataGridViewSortCompareEventArgs.cs
- TableStyle.cs
- Win32SafeHandles.cs
- AesManaged.cs
- CrossSiteScriptingValidation.cs
- Set.cs
- Grant.cs
- ReverseInheritProperty.cs
- InfoCardArgumentException.cs
- RootBuilder.cs
- KoreanLunisolarCalendar.cs
- ObjectMaterializedEventArgs.cs
- ApplicationInfo.cs
- FillBehavior.cs
- IsolatedStoragePermission.cs
- CustomUserNameSecurityTokenAuthenticator.cs
- AppModelKnownContentFactory.cs
- MethodExpr.cs
- HMACSHA384.cs
- SpoolingTask.cs
- NetSectionGroup.cs
- FacetEnabledSchemaElement.cs
- NullEntityWrapper.cs