- QUERY_SERVICE_CONFIGA structure (winsvc.h)
- Syntax
- Members
- Remarks
- Examples
- Configuring Services Using Configuration Files
- System.Configuration: Web.config and App.config
- Major Sections of the Configuration File
- The Element
- The Element
- The Element
- The Element
- The Element
- The Element
- The Element
- How to Use Binding and Behavior Configurations
- Behavior Merge
QUERY_SERVICE_CONFIGA structure (winsvc.h)
Contains configuration information for an installed service. It is used by the QueryServiceConfig function.
Syntax
Members
The type of service. This member can be one of the following values.
Value | Meaning |
---|---|
SERVICE_FILE_SYSTEM_DRIVER 0x00000002 | File system driver service. |
SERVICE_KERNEL_DRIVER 0x00000001 | Driver service. |
SERVICE_WIN32_OWN_PROCESS 0x00000010 | Service that runs in its own process. |
SERVICE_WIN32_SHARE_PROCESS 0x00000020 | Service that shares a process with other services. |
В
If the value is SERVICE_WIN32_OWN_PROCESS or SERVICE_WIN32_SHARE_PROCESS, and the service is running in the context of the LocalSystem account, the following type may also be specified.
Value | Meaning | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
SERVICE_INTERACTIVE_PROCESS 0x00000100 | The service can interact with the desktop. When to start the service. This member can be one of the following values.
The severity of the error, and action taken, if this service fails to start. This member can be one of the following values.
The fully qualified path to the service binary file. The path can also include arguments for an auto-start service. These arguments are passed to the service entry point (typically the main function). The name of the load ordering group to which this service belongs. If the member is NULL or an empty string, the service does not belong to a load ordering group. The startup program uses load ordering groups to load groups of services in a specified order with respect to the other groups. The list of load ordering groups is contained in the following registry value: A unique tag value for this service in the group specified by the lpLoadOrderGroup parameter. A value of zero indicates that the service has not been assigned a tag. You can use a tag for ordering service startup within a load order group by specifying a tag order vector in the registry located at: Tags are only evaluated for SERVICE_KERNEL_DRIVER and SERVICE_FILE_SYSTEM_DRIVER type services that have SERVICE_BOOT_START or SERVICE_SYSTEM_START start types. A pointer to an array of null-separated names of services or load ordering groups that must start before this service. The array is doubly null-terminated. If the pointer is NULL or if it points to an empty string, the service has no dependencies. If a group name is specified, it must be prefixed by the SC_GROUP_IDENTIFIER (defined in WinSvc.h) character to differentiate it from a service name, because services and service groups share the same name space. Dependency on a service means that this service can only run if the service it depends on is running. Dependency on a group means that this service can run if at least one member of the group is running after an attempt to start all members of the group. If the service type is SERVICE_WIN32_OWN_PROCESS or SERVICE_WIN32_SHARE_PROCESS, this member is the name of the account that the service process will be logged on as when it runs. This name can be of the form Domain\UserName. If the account belongs to the built-in domain, the name can be of the form .\UserName. The name can also be «LocalSystem» if the process is running under the LocalSystem account. If the service type is SERVICE_KERNEL_DRIVER or SERVICE_FILE_SYSTEM_DRIVER, this member is the driver object name (that is, \FileSystem\Rdr or \Driver\Xns) which the input and output (I/O) system uses to load the device driver. If this member is NULL, the driver is to be run with a default object name created by the I/O system, based on the service name. The display name to be used by service control programs to identify the service. This string has a maximum length of 256 characters. The name is case-preserved in the service control manager. Display name comparisons are always case-insensitive. This parameter can specify a localized string using the following format: The string with identifier StrID is loaded from DLLName; the Path is optional. For more information, see RegLoadMUIString. Windows ServerВ 2003 and WindowsВ XP:В В Localized strings are not supported until WindowsВ Vista. RemarksThe configuration information for a service is initially specified when the service is created by a call to the CreateService function. The information can be modified by calling the ChangeServiceConfig function. ExamplesThe winsvc.h header defines QUERY_SERVICE_CONFIG as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes. Configuring Services Using Configuration FilesConfiguring a Windows Communication Foundation (WCF) service with a configuration file gives you the flexibility of providing endpoint and service behavior data at the point of deployment instead of at design time. This topic outlines the primary techniques available. A WCF service is configurable using the .NET Framework configuration technology. Most commonly, XML elements are added to the Web.config file for an Internet Information Services (IIS) site that hosts a WCF service. The elements allow you to change details such as the endpoint addresses (the actual addresses used to communicate with the service) on a machine-by-machine basis. In addition, WCF includes several system-provided elements that allow you to quickly select the most basic features for a service. Starting with .NET Framework 4, WCF comes with a new default configuration model that simplifies WCF configuration requirements. If you do not provide any WCF configuration for a particular service, the runtime automatically configures your service with some standard endpoints and default binding/behavior. In practice, writing configuration is a major part of programming WCF applications. For more information, see Configuring Bindings for Services. For a list of the most commonly used elements, see System-Provided Bindings. For more information about default endpoints, bindings, and behaviors, see Simplified Configuration and Simplified Configuration for WCF Services. When deploying side by side scenarios where two different versions of a service are deployed, it is necessary to specify partial names of assemblies referenced in configuration files. This is because the configuration file is shared across all versions of a service and they could be running under different versions of the .NET Framework. System.Configuration: Web.config and App.configWCF uses the System.Configuration configuration system of the .NET Framework. When configuring a service in Visual Studio, use either a Web.config file or an App.config file to specify the settings. The choice of the configuration file name is determined by the hosting environment you choose for the service. If you are using IIS to host your service, use a Web.config file. If you are using any other hosting environment, use an App.config file. In Visual Studio, the file named App.config is used to create the final configuration file. The final name actually used for the configuration depends on the assembly name. For example, an assembly named «Cohowinery.exe» has a final configuration file name of «Cohowinery.exe.config». However, you only need to modify the App.config file. Changes made to that file are automatically made to the final application configuration file at compile time. In using an App.config, file the configuration system merges the App.config file with content of the Machine.config file when the application starts and the configuration is applied. This mechanism allows machine-wide settings to be defined in the Machine.config file. The App.config file can be used to override the settings of the Machine.config file; you can also lock in the settings in Machine.config file so that they get used. In the Web.config case, the configuration system merges the Web.config files in all directories leading up to the application directory into the configuration that gets applied. For more information about configuration and the setting priorities, see topics in the System.Configuration namespace. Major Sections of the Configuration FileThe main sections in the configuration file include the following elements. The bindings and behaviors sections are optional and are only included if required. The ElementThe services element contains the specifications for all services the application hosts. Starting with the simplified configuration model in .NET Framework 4, this section is optional. The ElementEach service has these attributes: name . Specifies the type that provides an implementation of a service contract. This is a fully qualified name which consists of the namespace, a period, and then the type name. For example «MyNameSpace.myServiceType» . behaviorConfiguration . Specifies the name of one of the behavior elements found in the behaviors element. The specified behavior governs actions such as whether the service allows impersonation. If its value is the empty name or no behaviorConfiguration is provided then the default set of service behaviors is added to the service. The ElementEach endpoint requires an address, a binding, and a contract, which are represented by the following attributes: address . Specifies the service’s Uniform Resource Identifier (URI), which can be an absolute address or one that is given relative to the base address of the service. If set to an empty string, it indicates that the endpoint is available at the base address that is specified when creating the ServiceHost for the service. binding . Typically specifies a system-provided binding like WSHttpBinding, but can also specify a user-defined binding. The binding specified determines the type of transport, security and encoding used, and whether reliable sessions, transactions, or streaming is supported or enabled. bindingConfiguration . If the default values of a binding must be modified, this can be done by configuring the appropriate binding element in the bindings element. This attribute should be given the same value as the name attribute of the binding element that is used to change the defaults. If no name is given, or no bindingConfiguration is specified in the binding, then the default binding of the binding type is used in the endpoint. contract . Specifies the interface that defines the contract. This is the interface implemented in the common language runtime (CLR) type specified by the name attribute of the service element. The ElementThe bindings element contains the specifications for all bindings that can be used by any endpoint defined in any service. The ElementThe binding elements contained in the bindings element can be either one of the system-provided bindings (see System-Provided Bindings) or a custom binding (see Custom Bindings). The binding element has a name attribute that correlates the binding with the endpoint specified in the bindingConfiguration attribute of the endpoint element. If no name is specified then that binding corresponds to the default of that binding type. For more information about configuring services and clients, see Configuring WCF services. The ElementThis is a container element for the behavior elements that define the behaviors for a service. The ElementEach behavior element is identified by a name attribute and provides either a system-provided behavior, such as throttling >, or a custom behavior. If no name is given then that behavior element corresponds to the default service or endpoint behavior. How to Use Binding and Behavior ConfigurationsWCF makes it easy to share configurations between endpoints using a reference system in configuration. Rather than directly assigning configuration values to an endpoint, binding-related configuration values are grouped in bindingConfiguration elements in the section. A binding configuration is a named group of settings on a binding. Endpoints can then reference the bindingConfiguration by name. The name of the bindingConfiguration is set in the element. The name must be a unique string within the scope of the binding type—in this case the , or an empty value to refer to the default binding. The endpoint links to the configuration by setting the bindingConfiguration attribute to this string. A behaviorConfiguration is implemented the same way, as illustrated in the following sample. Note that the default set of service behaviors are added to the service. This system allows endpoints to share common configurations without redefining the settings. If machine-wide scope is required, create the binding or behavior configuration in Machine.config. The configuration settings are available in all App.config files. The Configuration Editor Tool (SvcConfigEditor.exe) makes it easy to create configurations. Behavior MergeThe behavior merge feature makes it easier to manage behaviors when you want a set of common behaviors to be used consistently. This feature allows you to specify behaviors at different levels of the configuration hierarchy and have services inherit behaviors from multiple levels of the configuration hierarchy. To illustrate how this works assume you have the following virtual directory layout in IIS: \Web.config file has the following contents: And you have a child Web.config located at \Child\Web.config with the following contents: The service located at \Child\Service.svc will behave as though it has both the serviceDebug and serviceMetadata behaviors. The service located at \Service.svc will only have the serviceDebug behavior. What happens is that the two behavior collections with the same name (in this case the empty string) are merged. You can also clear behavior collections by using the tag and removed individual behaviors from the collection by using the tag. For example, the following two configuration results in the child service having only the serviceMetadata behavior: Behavior merge is done for nameless behavior collections as shown above and named behavior collections as well. Behavior merge works in the IIS hosting environment, in which Web.config files merge hierarchically with the root Web.config file and machine.config. But it also works in the application environment, where machine.config can merge with the App.config file. Behavior merge applies to both endpoint behaviors and service behaviors in configuration. If a child behavior collection contains a behavior that’s already present in the parent behavior collection, the child behavior overrides the parent. So if a parent behavior collection had and a child behavior collection had , the child behavior would override the parent behavior in the behavior collection and httpGetEnabled would be «true». |