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
- RootNamespaceAttribute.cs
- MimeFormatter.cs
- SafeFileHandle.cs
- GifBitmapEncoder.cs
- Visual.cs
- FileUpload.cs
- WpfWebRequestHelper.cs
- Bezier.cs
- RenderingBiasValidation.cs
- SecureStringHasher.cs
- Point3DAnimationUsingKeyFrames.cs
- PrinterUnitConvert.cs
- XamlHostingSectionGroup.cs
- TypefaceMap.cs
- HttpException.cs
- ConnectionStringSettingsCollection.cs
- ModelUIElement3D.cs
- FileSystemEventArgs.cs
- TdsParserHelperClasses.cs
- DataColumn.cs
- TextTreeTextNode.cs
- XmlSchemaSimpleType.cs
- BounceEase.cs
- DeflateStream.cs
- SHA1.cs
- XmlSortKey.cs
- ContentElementCollection.cs
- PropertyState.cs
- KeyValueConfigurationCollection.cs
- Decimal.cs
- DataRecordInternal.cs
- SignatureDescription.cs
- NonParentingControl.cs
- HMAC.cs
- FunctionDetailsReader.cs
- SerialPort.cs
- ResourceDisplayNameAttribute.cs
- MatrixConverter.cs
- TextBoxAutoCompleteSourceConverter.cs
- PropertyExpression.cs
- SocketException.cs
- ReadWriteSpinLock.cs
- ButtonBase.cs
- baseaxisquery.cs
- AppearanceEditorPart.cs
- ReadWriteSpinLock.cs
- ExtendedProperty.cs
- QilChoice.cs
- WebPartTransformerCollection.cs
- XmlSignificantWhitespace.cs
- PersonalizationStateInfoCollection.cs
- TableItemStyle.cs
- StoragePropertyMapping.cs
- ColumnResult.cs
- ByteStack.cs
- SecurityUtils.cs
- ToolStripDropDownClosingEventArgs.cs
- DesignBindingValueUIHandler.cs
- EditBehavior.cs
- InternalTypeHelper.cs
- UserControlParser.cs
- Pair.cs
- FaultCallbackWrapper.cs
- graph.cs
- QueryStringParameter.cs
- SimpleNameService.cs
- CachingHintValidation.cs
- fixedPageContentExtractor.cs
- OledbConnectionStringbuilder.cs
- SafeWaitHandle.cs
- HwndHostAutomationPeer.cs
- BooleanExpr.cs
- ExecutionContext.cs
- ColorConverter.cs
- Label.cs
- SafeSecurityHandles.cs
- SqlMethodTransformer.cs
- SchemaAttDef.cs
- DataGridViewComboBoxCell.cs
- AnimationStorage.cs
- TemplateNodeContextMenu.cs
- OrderedDictionary.cs
- NamedPermissionSet.cs
- GPPOINTF.cs
- CaseDesigner.xaml.cs
- SqlDeflator.cs
- PreApplicationStartMethodAttribute.cs
- localization.cs
- ZoneButton.cs
- CharUnicodeInfo.cs
- SoapHeaders.cs
- NamespaceEmitter.cs
- ThemeInfoAttribute.cs
- NestedContainer.cs
- PerfCounters.cs
- ListItemCollection.cs
- ConfigurationPropertyCollection.cs
- HttpEncoder.cs
- PermissionListSet.cs
- OleDbParameter.cs