什么是知识收件匣的共享仓库?
知识收件匣的共享仓库是一个基于Activex的COM组件,允许你创建逻辑的仓库,存储对象和值。这种信息在没有被覆盖之前一直保存在系统中。简单的QTP代码如下:
'Create the shared store
Set oSharedStore = CreateObject ("KnowledgeInbox.SharedStore")
'Add a new store
Set oStore = oSharedStore.AddStore("GeneralTest")
'Create a dictionary object in shared store
Set oDict = oSharedStore.CreateObject("Scripting.Dictionary")
'Add the dictionary object to the store
oStore.AddItem "TestDictionary" , oDict
'Update some values in dictionary
oDict("CA") = "California"
'Destroy the object
Set oDict = Nothing
'Instruct shared to store to remain in memory
oSharedStore.PersistInMemory = True
'Destroy the shared store
Set oSharedStore = Nothing
关闭QTP并打开一个VBScript的记事本
'Create the shared object store
Set oSharedStore = CreateObject ("KnowledgeInbox.SharedStore")
'Get the specified store
Set oStore = oSharedStore.GetStore("GeneralTest")
'Get the specified object from the store
Set oDict = oStore.GetItem ("TestDictionary")
'Will display california
MsgBox oDict("CA")
'Now instruct shared store to unload when destroyed
oSharedStore.PersistInMemory = False
'Destroy the shared store
Set oSharedStore = Nothing