You are reading help file online using chmlib.com
|
Object: SpObjectToken
Type: Hidden
The GetStorageFileName method creates a storage file for data associated with the object token.
SpObjectToken.GetStorageFileName(
ObjectStorageCLSID As String,
KeyName As String,
FileName As String,
Folder As SpeechTokenShellFolder
) As String
A String variable containing the path of the storage file.
The following Visual Basic form code demonstrates the GetStorageFileName and RemoveStorageFileName methods. To run this code, create a form with the following controls:
Paste this code into the Declarations section of the form.
The operations performed in this example can best be viewed with REGEDIT.EXE. For a discussion of Registry issues, please see the ISpeechDataKey interface.
The Form_Load procedure creates a new SpObjectToken object, and sets its ID property to a new subfolder called Demo within the Voices\Tokens folder. The True parameter of the SetId call forces the creation of this folder, if it does not already exist.
The Command1 procedure creates a data key object which references the new Demo folder, and uses the data key to write a value into the folder.
The Command2 procedure calls the GetStorageFileName method. After this call, the Demo folder contains a subfolder called {CDD1141B-82FB-405c-99BE-69A793A92D87}. This is the CLSID used as a parameter of the GetStorageFileName method. Within this is a folder called Files, which contains a the storage file path in a value called Demo.
The Command3 procedure calls the RemoveStorageFileName method. This deletes the storage file, and removes the Demo value from the Files folder.
The Command4 procedure uses the ISpeechDataKey.Remove method to delete the {CDD1141B-82FB-405c-99BE-69A793A92D87} folder and Demo folders.
Option Explicit
Dim T As SpeechLib.SpObjectToken 'one object token
Dim C As SpeechLib.SpObjectTokenCategory 'one object token category
Dim K As SpeechLib.ISpeechDataKey '
Dim ID As String
Dim SF As String 'Storage file name
Dim TestCLSID As String
Private Sub Command1_Click()
'Set data key object to the demo voice's folder,
'Write a CLSID value
Set K = T.DataKey
K.SetStringValue "CLSID", TestCLSID
End Sub
Private Sub Command2_Click()
'Create a storage file for the token
SF = T.GetStorageFileName(TestCLSID, "Demo", vbNullString, _
STSF_FlagCreate + STSF_AppData)
MsgBox SF
End Sub
Private Sub Command3_Click()
'Remove the storage file
Call T.RemoveStorageFileName(TestCLSID, "Demo", True)
End Sub
Private Sub Command4_Click()
'Remove the "{CDD1141B-82FB-405c-99BE-69A793A92D87}" folder,
'and the "Demo" folder
T.Remove TestCLSID
T.Remove ""
End Sub
Private Sub Form_Load()
TestCLSID = "{CDD1141B-82FB-405c-99BE-69A793A92D87}"
'Create new category object, set it to Voices category
Set C = New SpObjectTokenCategory
C.SetId SpeechCategoryVoices
'Create new token object, and set its ID
'to the path of a folder which does not exist
'"True" parameter creates the folder
Set T = New SpObjectToken
ID = SpeechCategoryVoices & "\Tokens\Demo"
T.SetId ID, , True
End Sub
You are reading help file online using chmlib.com
|