ICOMAdminCatalog2::CreateServiceForApplication method (comadmin.h)

Configures a COM+ application to run as a Windows service.

Syntax

HRESULT CreateServiceForApplication(
  BSTR         bstrApplicationIDOrName,
  BSTR         bstrServiceName,
  BSTR         bstrStartType,
  BSTR         bstrErrorControl,
  BSTR         bstrDependencies,
  BSTR         bstrRunAs,
  BSTR         bstrPassword,
  VARIANT_BOOL bDesktopOk
);

Parameters

bstrApplicationIDOrName

The application ID or name of the application.

bstrServiceName

The service name of the application. This name is the internal name used by the service control manager (SCM), not the display name.

bstrStartType

When to start the service. The valid arguments are the options of the dwStartType parameter of the CreateService function. The arguments must be in quotes. The following are the valid arguments: SERVICE_BOOT_START, SERVICE_SYSTEM_START, SERVICE_AUTO_START, SERVICE_DEMAND_START, and SERVICE_DISABLED.

bstrErrorControl

The severity of the error if this service fails to start during startup. The error determines the action taken by the startup program if failure occurs. The valid arguments are the options of the dwErrorControl parameter of the CreateService function. The arguments must be in quotes. The following are the valid arguments: SERVICE_ERROR_IGNORE, SERVICE_ERROR_NORMAL, SERVICE_ERROR_SEVERE, and SERVICE_ERROR_CRITICAL.

bstrDependencies

A list of dependencies for the service. There are two possible formats for the string: a standard null-delimited, double-null-terminated string (exactly as documented for CreateService); or a script-friendly list of service names separated by "" (an invalid character to have in a service name). The rpcss service is implicit in this parameter and does not need to be specified.

bstrRunAs

The user name to run this service as. If this parameter is NULL, the service will run as Local Service.

bstrPassword

The password for the system user account. This parameter must be NULL if the service is configured to run as Local Service.

bDesktopOk

Indicates whether the service should be allowed to interact with the desktop. This parameter is valid only when the service is marked as Local Service and must be FALSE otherwise.

Return value

This method can return the standard return values E_INVALIDARG, E_OUTOFMEMORY, E_UNEXPECTED, E_FAIL, and S_OK.

Remarks

A service created by this method can be removed using the DeleteServiceForApplication method.

Requirements

   
Minimum supported client Windows XP [desktop apps only]
Minimum supported server Windows Server 2003 [desktop apps only]
Target Platform Windows
Header comadmin.h

See also

ICOMAdminCatalog2