IPortableDeviceWebControl
COMIDispatch (デュアル)comobj 経由でメソッド名による遅延バインド呼び出しができます(vtableインデックス不要)。公式ドキュメント
Windows ストアアプリ内で WPD Automation Device オブジェクトを生成できるファクトリを表します。
解説(Remarks)
例
MTP デバイスサービスを使用する WPD デバイスの場合、次のようにして COM Automation オブジェクトを作成し、デバイスを操作できます。
deviceFactory = new ActiveXObject("PortableDeviceAutomation.Factory");
var device = deviceFactory.getDeviceFromId(deviceId);
// Get the first service on the device
var deviceService = device.services[0];
メソッド 2
vtbl = vtable インデックス(0始まり)。IDispatch 実装のため HSP ではメソッド名でも呼べます(上記)。低レベルの index 呼び出し用に vtbl も掲載。0〜2 は IUnknown。
指定された WPD デバイス識別子に対応する WPD Automation Device オブジェクトを生成します。(IPortableDeviceWebControl.GetDeviceFromId)
| deviceId | LPWSTR | in | 現在接続されている WPD デバイスをプラグアンドプレイが識別するために使用する BSTR です。特定のデバイスのプラグアンドプレイ (PnP) 識別子は、WPD C++/COM API の IPortableDeviceManager::GetDevices メソッドから取得できます。 Windows ストアアプリでは、Windows.Devices.Portable.ServiceDevice.GetDeviceSelector または Windows.Devices.Portable.ServiceDevice.GetDeviceSelectorFromServiceId を使用してセレクター文字列を取得し、それを Windows.Devices.Enumeration.DeviceInformation.FindAllAsync に渡すことで、WPD デバイスの PnP 識別子を取得できます。FindAllAsync は、現在接続されている WPD デバイスを表す DeviceInformation オブジェクトのコレクションを返します。DeviceInformation オブジェクトの Id プロパティが、そのデバイスの PnP 識別子です。 |
| ppDevice | IDispatch** | out | WPD Automation Device オブジェクトの IDispatch 実装へのポインターが格納されます。 |
戻り値
戻り値には次の表に示す値が含まれますが、これらに限定されません。
| 戻り値 | 説明 |
|---|---|
| メソッドは成功しました。 | |
| Windows 8 上で動作する Windows ストアアプリ以外からこのメソッドを呼び出した場合、このエラーコードが返されます。 |
解説(Remarks)
例
MTP デバイスサービスを使用する WPD デバイスの場合、次のようにして COM Automation オブジェクトを作成し、デバイスを操作できます。
deviceFactory = new ActiveXObject("PortableDeviceAutomation.Factory");
var device = deviceFactory.getDeviceFromId(deviceId);
// Get the first service on the device
var deviceService = device.services[0];
指定された WPD デバイス識別子に対応する WPD Automation Device オブジェクトを非同期に生成します。
| deviceId | LPWSTR | in | 現在接続されている WPD デバイスをプラグアンドプレイが識別するために使用する BSTR です。特定のデバイスのプラグアンドプレイ (PnP) 識別子は、WPD C++/COM API の IPortableDeviceManager::GetDevices メソッドから取得できます。 Windows ストアアプリでは、Windows.Devices.Portable.ServiceDevice.GetDeviceSelector または Windows.Devices.Portable.ServiceDevice.GetDeviceSelectorFromServiceId を使用してセレクター文字列を取得し、それを Windows.Devices.Enumeration.DeviceInformation.FindAllAsync に渡すことで、WPD デバイスの PnP 識別子を取得できます。FindAllAsync は、現在接続されている WPD デバイスを表す DeviceInformation オブジェクトのコレクションを返します。DeviceInformation オブジェクトの Id プロパティが、そのデバイスの PnP 識別子です。 |
| pCompletionHandler | IDispatch* | in | 完了ハンドラーです。 |
| pErrorHandler | IDispatch* | inoptional | エラーハンドラーです。 |
戻り値
戻り値には次の表に示す値が含まれますが、これらに限定されません。
| 戻り値 | 説明 |
|---|---|
| メソッドは成功しました。 | |
| Windows 8 上で動作する Windows ストアアプリ以外からこのメソッドを呼び出した場合、このエラーコードが返されます。 |
解説(Remarks)
例
MTP デバイスサービスを使用する WPD デバイスの場合、次のようにして COM Automation オブジェクトを作成し、デバイスを操作できます。
deviceFactory = new ActiveXObject("PortableDeviceAutomation.Factory");
// Get the first device object from the device factory
deviceFactory.getDeviceFromIdAsync(deviceInfoElement.id,
function (device) {
// Get the first service on the device
var deviceService = device.services[0];
// Get the first storage on the device
var deviceStorage = devices.storages[0];
// …
}
}
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
HSP用 COM定義
#usecom / #comfunc によるHSPのCOM呼び出し定義。数字は vtbl インデックス(0始まり)。クラスIDが無い場合 #usecom の末尾は "{}"、ある場合は "{CLSID}"。
#define global IID_IPortableDeviceWebControl "{94FC7953-5CA1-483A-8AEE-DF52E7747D00}"
#usecom global IPortableDeviceWebControl IID_IPortableDeviceWebControl "{186DD02C-2DEC-41B5-A7D4-B59056FADE51}"
#comfunc global IPortableDeviceWebControl_GetDeviceFromId 7 wstr,sptr
#comfunc global IPortableDeviceWebControl_GetDeviceFromIdAsync 8 wstr,sptr,sptr
; ※数字は vtbl インデックス(0始まり)。0/1/2 は IUnknown(QueryInterface/AddRef/Release)。
; ※#usecom 末尾は CoCreateInstance 用のクラスID(コクラスCLSID, SDKから自動取得)。
; ※ハンドル/void*等の不透明ポインタは IronHSP では intptr 指定が可能。
; ※IDispatch 実装。HSP では comobj 経由でメソッド名による呼び出しも可能(vtbl 不要)。