[函式探索可用於需求一節中指定的作業系統。 後續版本可能會變更或無法使用。]
建立函式實例。 所有函式實例都應該使用此方法建立。 不應使用支援 IFunctionInstance 的其他實作。
語法
HRESULT CreateInstance(
[in] const WCHAR *pszSubCategory,
[in] const WCHAR *pszProviderInstanceIdentity,
[in] INT_PTR iProviderInstanceContext,
[in] IPropertyStore *pIPropertyStore,
[in] IFunctionDiscoveryProvider *pIFunctionDiscoveryProvider,
[out] IFunctionInstance **ppIFunctionInstance
);
參數
[in] pszSubCategory
函式實例的子類別字串。 請參閱 子類別定義。
[in] pszProviderInstanceIdentity
提供者實例標識碼。
函式探索會使用此標識符來確保 IFunctionInstance::GetID 所傳回的函式實例識別碼是唯一的。 為此,函式探索會將前置詞附加至傳遞至 pszProviderInstanceIdentity 的標識符,以確保指定函式實例標識碼在所有提供者中都是唯一的。 實作者只需要確保 pszProviderInstanceIdentity 可唯一識別提供者範圍內的裝置、資源或實例。
此字串會傳回給呼叫 IFunctionInstance::GetProviderInstanceID 的用戶端應用程式。
此字串的大小沒有上限。
[in] iProviderInstanceContext
與特定函式實例相關聯的內容。
[in] pIPropertyStore
IPropertyStore 介面的指標。
[in] pIFunctionDiscoveryProvider
IFunctionDiscoveryProvider 提供者實例的指標,建立此函式實例。
[out] ppIFunctionInstance
IFunctionInstance 介面的指標。
傳回值
如果此方法成功,則會傳回 S_OK。 否則,它會傳回 HRESULT 錯誤碼。
備註
提供者應該指定子類別 (可以是 NULL) 、實例識別碼、提供者配置的內容 (視需要) ,以及選擇性屬性存放區。
CreateInstance 會將適當初始化的函式實例傳回給提供者。
提供者所指定的內容將會傳回給提供者,以供所有後續的函式實例相關方法使用,例如 InstanceReleased、InstancePropertyStoreOpen、InstancePropertyStoreFlush 和 InstanceQueryService。
提供者必須保證提供者參考計數不會移至零,可能是在另一個線程上,同時呼叫 CreateInstance 。
規格需求
| 需求 | 值 |
|---|---|
| 最低支援的用戶端 | Windows Vista [僅限傳統型應用程式] |
| 最低支援的伺服器 | Windows Server 2008 [僅限傳統型應用程式] |
| 目標平台 | Windows |
| 標頭 | functiondiscoveryprovider.h |