Share via


ISpObjectToken::RemoveStorageFileName (SAPI 5.4)

Microsoft Speech API 5.4

ISpObjectToken::RemoveStorageFileName

ISpObjectToken::RemoveStorageFileName removes the object token file name.

  
    HRESULT RemoveStorageFileName(
   REFCLSID       clsidCaller,
   LPCWSTR       *pszKeyName,
   BOOL           fDeleteFile
);

Parameters

  • clsidCaller
    [in] Globally unique identifier (GUID) of the calling object.
  • pszKeyName
    [in] Address of a null-terminated string containing the registry key name.
  • fDeleteFile
    [in] Value specifying if the file should be deleted. TRUE deletes the file afterward; FALSE does not.

Return values

Value
S_OK
E_INVALIDARG
SPERR_UNINITIALIZED
SPERR_TOKEN_DELETED
FAILED(hr)

Example

The following code snippet creates a test file, removes it and manually deletes it. It may also have been deleted automatically by setting fDeleteFile to TRUE.

  
// Declare local identifiers:
HRESULT                   hr = S_OK;
CComPtr<ISpObjectToken>   cpObjectToken;
GUID                      guid0;
WCHAR                     *cpFileName;
ULONG                     CSIDL_LOCAL_APPDATA = 28;
ULONG                     CSIDL_FLAG_CREATE = 32768;

// Get the default text-to-speech engine token.
hr = SpGetDefaultTokenFromCategoryId(SPCAT_VOICES, &cpObjectToken;);

if (SUCCEEDED (hr))
{
   hr = CoCreateGuid(&guid0;);
}

if (SUCCEEDED (hr))
{
   // Create file with default format and store it in folder that
   // contains application-specific data that does not roam.
   hr = cpObjectToken->GetStorageFileName(guid0, L"TestFile", NULL, CSIDL_FLAG_CREATE|CSIDL_LOCAL_APPDATA, &cpFileName;);
}

if (SUCCEEDED (hr))
{
   // Remove object token.
   hr = cpObjectToken->RemoveStorageFileName(guid0, L"TestFile", false);
}

if (SUCCEEDED(hr))
{
   // Do stuff here.
}