Win32 API 日本語リファレンス
ホームDevices.PortableDevices › IPortableDeviceWebControl

IPortableDeviceWebControl

COMIDispatch (デュアル)
IDispatch を実装(デュアルインターフェース)。HSP では comobj 経由でメソッド名による遅延バインド呼び出しができます(vtableインデックス不要)。
IID94fc7953-5ca1-483a-8aee-df52e7747d00継承元IDispatch呼び出し名前(IDispatch) または vtbl自前メソッド開始 vtbl7

公式ドキュメント

Windows ストアアプリ内で WPD Automation Device オブジェクトを生成できるファクトリを表します。

解説(Remarks)

注意 このインターフェイスは Windows ストアアプリでのみ使用できます。

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。

vtbl 7 HRESULT GetDeviceFromId(LPWSTR deviceId, IDispatch** ppDevice)

指定された WPD デバイス識別子に対応する WPD Automation Device オブジェクトを生成します。(IPortableDeviceWebControl.GetDeviceFromId)

deviceIdLPWSTRin

現在接続されている 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 識別子です。

ppDeviceIDispatch**outWPD Automation Device オブジェクトの IDispatch 実装へのポインターが格納されます。

戻り値

戻り値には次の表に示す値が含まれますが、これらに限定されません。

戻り値 説明
S_OK
メソッドは成功しました。
E_ACCESSDENIED
Windows 8 上で動作する Windows ストアアプリ以外からこのメソッドを呼び出した場合、このエラーコードが返されます。

解説(Remarks)

注意 このメソッドは Windows ストアアプリでのみ使用できます。

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];
vtbl 8 HRESULT GetDeviceFromIdAsync(LPWSTR deviceId, IDispatch* pCompletionHandler, IDispatch* pErrorHandler)

指定された WPD デバイス識別子に対応する WPD Automation Device オブジェクトを非同期に生成します。

deviceIdLPWSTRin

現在接続されている 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 識別子です。

pCompletionHandlerIDispatch*in完了ハンドラーです。
pErrorHandlerIDispatch*inoptionalエラーハンドラーです。

戻り値

戻り値には次の表に示す値が含まれますが、これらに限定されません。

戻り値 説明
S_OK
メソッドは成功しました。
E_ACCESSDENIED
Windows 8 上で動作する Windows ストアアプリ以外からこのメソッドを呼び出した場合、このエラーコードが返されます。

解説(Remarks)

注意 このメソッドは Windows ストアアプリでのみ使用できます。

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 の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.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 不要)。