IUPnPRegistrar::RegisterRunningDevice method (upnphost.h)

The RegisterRunningDevice method registers a running device with the device host. The device information is stored by the device host. Then, the device host returns a device identifier and publishes and announces the device on the network. The publication of this device does not persist across system boots.

Syntax

HRESULT RegisterRunningDevice(
  [in]  BSTR     bstrXMLDesc,
  [in]  IUnknown *punkDeviceControl,
  [in]  BSTR     bstrInitString,
  [in]  BSTR     bstrResourcePath,
  [in]  long     nLifeTime,
  [out] BSTR     *pbstrDeviceIdentifier
);

Parameters

[in] bstrXMLDesc

Specifies the XML device description template of the device to register.

[in] punkDeviceControl

Specifies the IUnknown pointer to the device's device control object.

[in] bstrInitString

Identifies the initialization string specific to the device. This string is later passed to IUPnPDeviceControl::Initialize.

[in] bstrResourcePath

Specifies the location of the resource directory of the device. This resource directory contains the icon files and service descriptions that are specified in the device description template bstrXMLDesc.

[in] nLifeTime

Specifies the lifetime of the device announcement, in seconds. After the timeout expires, the announcements are refreshed. If you specify zero, the default value of 1800 (30 minutes) is used. The minimum allowable value is 900 (15 minutes); if you specify anything less than 900, an error is returned.

[out] pbstrDeviceIdentifier

Receives the device identifier. Use this identifier when unregistering or re-registering the device. Save this Device ID; you must use it when calling UnregisterDevice.

Return value

If the method succeeds, the return value is S_OK. Otherwise, the method returns one of the COM error codes defined in WinError.h, or one of the following UPnP-specific error codes.

Note  If bstrResourcePath is too long, this method returns the value 0x80070002.
 
Return code Description
UPNP_E_DUPLICATE_NOT_ALLOWED
A duplicate element exists.
UPNP_E_DUPLICATE_SERVICE_ID
A duplicate service ID for a service within the same parent device exists.
UPNP_E_INVALID_DESCRIPTION
The device description is not valid.
UPNP_E_INVALID_ICON
An error is present in the icon element of the device description.
UPNP_E_INVALID_SERVICE
An error is present in a service element in the device description.
UPNP_E_REQUIRED_ELEMENT_ERROR
A required element is missing.

Remarks

The client that invokes this method must be able to impersonate LocalService in order to complete the processing of this method.

The IUPnPDeviceControl::Initialize method is invoked when the first control or event request is received.

Use the identifier returned in pbstrDeviceIdentifier when invoking UnregisterDevice or IUPnPReregistrar::ReregisterRunningDevice.

The registration of this device does not persist across system boots.

Common errors that can occur when invoking this function include:

  • The necessary COM object was not found.
  • There is no access to the COM object for LocalService.
  • Subordinate COM interfaces.
  • The XML description limits (see Creating a Device Description).
  • Evented variables did not return success codes and the device was shut down.
  • The service description was invalid. Use validatesd.exe to ensure that service descriptions are valid.
  • The service did not implement IUPnPEventSource and did not return a success code to IUPnPEventSource::Advise and the device was shut down.

Requirements

Requirement Value
Minimum supported client Windows XP [desktop apps only]
Minimum supported server None supported
Target Platform Windows
Header upnphost.h
DLL Upnphost.dll

See also

IUPnPRegistrar

IUPnPRegistrar::UnregisterDevice

IUPnPReregistrar