Skip to main content
PrintExtensionContext.FromDeviceId | fromDeviceId method

Gets the context for the printer extension object based on the DeviceInformation ID.

Syntax


var object = Windows.Devices.Printers.Extensions.PrintExtensionContext.fromDeviceId(deviceId);

public static object FromDeviceId(
  string deviceId
)

Public Shared Function FromDeviceId(
  deviceId As String 
) As Object

public:
static Object^ FromDeviceId(
  String^ deviceId
)

Parameters

deviceId

Type: String [JavaScript] | System.String [.NET] | Platform::String [C++]

The device information ID for the print device.

Return value

Type: Object [JavaScript] | System.Object [.NET] | Platform::Object [C++]

Pointer to the context.

Remarks

The following JavaScript code snippet retrieves the PrinterExtensionContext using a DeviceInformation ID, and then uses the context to create a helper object:


// This function runs when the user taps the Back button
function getInkStatus(deviceId) {
    var responseString;
    try {
        var context = Windows.Devices.Printers.Extensions.
            PrintExtensionContext.fromDeviceId(deviceId);
        var helper = new Microsoft.Samples.Printing.WwaDca.
            PrintHelperClass(context);
        var responseString = helper.getInkLevel(1);
    } catch (e) {
        responseString = "deviceId: " + deviceId + 
            " Message: " + e.message;
    }
    return responseString
}

For more information about using FromDeviceId and the PrinterExtensionContext class, see the Windows Store device app for Printers whitepaper.

Requirements (Windows 10 device family)

Device family

Desktop, introduced version 10.0.10240.0

API contract

Windows.Devices.Printers.extensions.extensionsContract, introduced version 1.0

Namespace

Windows.Devices.Printers.Extensions
Windows::Devices::Printers::Extensions [C++]

Metadata

Windows.Devices.Printers.extensions.extensionsContract.winmd

Requirements (Windows 8.x and Windows Phone 8.x)

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

None supported

Namespace

Windows.Devices.Printers.Extensions
Windows::Devices::Printers::Extensions [C++]

Metadata

Windows.winmd

See also

Windows Store device app for Printers
PrintExtensionContext