You are reading help file online using chmlib.com
|
ISpObjectToken::CreateInstance creates an instance of an object.
HRESULT CreateInstance(
IUnknown *pUnkOuter,
DWORD dwClsContext,
REFIID riid,
void **ppvObject
);
Value | Description |
---|---|
S_OK | Function completed successfully. |
E_POINTER | ppvObject is invalid or bad. |
E_INVALIDARG | pUnkOuter is invalid or bad. |
SPERR_UNINITIALIZED | Either the data key or the token delegator interface is not initialized. |
SPERR_TOKEN_DELETED | Key has been deleted. |
FAILED(hr) | Appropriate error message. |
This method is used to create the underlying object that the object token represents. This method looks at the CLSID value stored in the object token and creates a COM object from this CLSID.
For example, when this method is called on an object token from the audio input category, an audio object that implements ISpStreamFormat will be created and returned.
This method is not used to create speech recognition or text-to-speech engines. Instead, an SpRecognizer or SpVoice object is created and the engine is then created by passing an object token to the ISpRecognizer::SetRecognizer or ISpVoice::SetVoice methods.
The following code snippet creates an InProc server instance.
HRESULT hr;
CComPtr<ISpObjectToken> cpSpObjectToken;
CComPtr<ISpObjectWithToken> cpSpObjectWithToken;
hr = SpGetDefaultTokenFromCategoryId(SPCAT_VOICES, &cpSpObjectToken);
//Check return value
hr = cpSpObjectToken->CreateInstance( NULL, CLSCTX_INPROC_SERVER, IID_ISpObjectWithToken, (void **)&cpSpObjectWithToken);
//Check return value
You are reading help file online using chmlib.com
|