Share via


Device object

The Device Object represents the current device instance and is the entry point into WPD Automation. The Device Object provides access and enumeration of device services and storages as well as access to device specific properties, events, and services.

A Device Object is created through the following property of a scripting host.

var deviceObject = window.external;

Note

A Device Object is functional only while the physical device that it represents is connected. Any operations performed on a Device Object after the physical device is disconnected will return an error and raise a DISP_E_EXCEPTION exception, with pExcepInfo filled out.

Members

The Device object has these types of members:

Events

The Device object has these events.

Event Description
onDeviceReset Occurs when the device is about to reset.
onDeviceUpdated Occurs when the device has been updated, as when a device property has been changed.

Methods

The Device object has these methods.

Method Description
GetServicesByType Returns a collection of services for the specified service type.

Properties

The Device object has these properties.

Property Access type Description
Services
Read-only
Provides read-only access to a collection of all the services on the device.
Storages
Read-only
Provides read-only access to a collection of all the legacy storages on the device.
WpdProperty
Read/write
Gets or sets the value of a device-specific property.

Requirements

Minimum supported client
Windows 7 [desktop apps only]
Minimum supported server
Windows Server 2008 R2 [desktop apps only]

See also

About the Device Object

Service Object

Storage Object

WPD Automation Reference

WPDObject