ISpTokenUI::IsUISupported (SAPI 5.4)

Speech API 5.4
Microsoft Speech API 5.4


ISpTokenUI::IsUISupported determines if the specified UI type is supported by the token.

[local] HRESULT IsUISupported(
   LPCWSTR       *pszTypeOfUI,
   void          *pvExtraData,
   ULONG          cbExtraData,
   IUnknown      *punkObject,
   BOOL          *pfSupported


[in] Address of a null-terminated string containing the object's UI type.
[in] Pointer to additional information needed for the object. The ISpTokenUI object implementer dictates the format and usage of the data provided.
[in] Size, in bytes, of the ExtraData. The ISpTokenUI object implementer dictates the format and usage of the data provided.
[in] Address of the object's IUnknown interface. See Remarks section.
[out] Address of a variable that receives the value indicating support for the interface. This value is set to TRUE when this interface is supported and FALSE otherwise. If this value is TRUE, but the return code is S_FALSE, the UI type (pszTypeOfUI) is supported, but not with the current parameters or run-time environment. Check with the implementer of the UI object to verify run-time requirements.

Return values

S_OKFunction completed successfully.
S_FALSEThe UI is supported but not with the current run-time environment or parameters.
E_INVALIDARGOne or more parameters are invalid.
E_POINTERInvalid or bad pointer.
FAILED(hr)Error returned by UI object.


When asking a token to display a particular piece of UI, the token may require extra functionality that only it understands. Common implementation practice for accessing this functionality is to QueryInterface off of a known IUnknown interface. The caller of ISpTokenUI::IsUISupported can set the punkObject parameter with the necessary IUnknown interface. For example, asking to display Speech Recognition Training UI requires that a specific SR engine be used.


The following code snippet illustrates the use of ISpTokenUI::IsUISupported using SPDUI_AudioProperties.

// Declare local identifiers:
HRESULT                      hr = S_OK;
CComPtr<ISpTokenUI>          cpTokenUI;
CComPtr<ISpObjectToken>      cpObjectToken;
BOOL                         fSupported;

// Get the default input audio object token.
hr = SpGetDefaultTokenFromCategoryId(SPCAT_AUDIOIN, &cpObjectToken;);

if (SUCCEEDED(hr))
   // Get the object token's UI.
   hr = cpObjectToken->QueryInterface(&cpTokenUI;);
if (SUCCEEDED(hr))
   // Check if the default audio input object has UI for Properties.
   hr = cpTokenUI->IsUISupported(SPDUI_AudioProperties, NULL, NULL, NULL, &fSupported;);

if (SUCCEEDED(hr))
   // If fSupported == TRUE, then default audio input
   // object has UI for Properties; so, do stuff here.