PrintExtensionContext.FromDeviceId | fromDeviceId method

Applies to Windows only

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

Syntax


var object = Windows.Devices.Printers.Extensions.PrintExtensionContext.fromDeviceId(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

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

 

 

Show:
© 2014 Microsoft