IFunctionDiscovery::AddInstance method (functiondiscoveryapi.h)
[Function Discovery is available for use in the operating systems specified in the Requirements section. It may be altered or unavailable in subsequent versions.]
Creates or modifies a function instance.
Syntax
HRESULT AddInstance(
[in] SystemVisibilityFlags enumSystemVisibility,
[in] const WCHAR *pszCategory,
[in] const WCHAR *pszSubCategory,
[in] const WCHAR *pszCategoryIdentity,
[out] IFunctionInstance **ppIFunctionInstance
);
Parameters
[in] enumSystemVisibility
A SystemVisibilityFlags value that specifies whether the created function instance is visible system wide or only to the current user.
[in] pszCategory
The category of the created function instance. See Category Definitions.
[in] pszSubCategory
The subcategory of the created function instance. See Subcategory Definitions. The maximum length of this string is MAX_PATH.
[in] pszCategoryIdentity
The provider instance identifier string. This string is returned from GetProviderInstanceID.
[out] ppIFunctionInstance
A pointer to an IFunctionInstance interface pointer that receives the function instance.
Return value
Possible return values include, but are not limited to, the following.
Return code/value | Description |
---|---|
|
The method completed successfully. |
|
The value of enumSystemVisibility, pszCategory, or pszCategoryIdentity is invalid. |
|
The method is unable to allocate the memory required to perform this operation. |
|
The user has insufficient access permission to perform the requested action. |
|
The provider does not support adding function instances directly using the AddInstance method. |
|
The value of pszCategory or pszSubCategory is unknown. |
|
An invalid parameter was specified. This error is returned when the length of the pszSubCategory string exceeds MAX_PATH. |
Remarks
This method temporarily creates a new function instance for the specified category and subcategory. The provider that implements the category is responsible for persisting the metadata associated with the newly created function instance using the IFunctionDiscoveryProviderFactory::CreateInstance method.
The function instance is not written to the registry if its associated property store does not have any values. Use the IFunctionInstance::OpenPropertyStore method to check the property store values.
If a function instance already exists for the specified category and subcategory, the existing registry entry is overwritten. The AddInstance method returns S_OK. The Function Discovery change notification process invokes the calling application's IFunctionDiscoveryNotification::OnUpdate method with enumQueryUpdateAction set to QUA_CHANGE.
Access permission to change HKEY_LOCAL_MACHINE\SYSTEM registry keys is required in order to add or remove function instances using the registry provider (Administrator or Power User access).
Requirements
Requirement | Value |
---|---|
Minimum supported client | Windows Vista [desktop apps only] |
Minimum supported server | Windows Server 2008 [desktop apps only] |
Target Platform | Windows |
Header | functiondiscoveryapi.h |
DLL | FunDisc.dll |