ActiveX™ Technology for Interactive Software Agents icon

ActiveX™ Technology for Interactive Software Agents




Скачати 402.6 Kb.
НазваActiveX™ Technology for Interactive Software Agents
Сторінка1/13
Дата20.09.2012
Розмір402.6 Kb.
ТипДокументи
  1   2   3   4   5   6   7   8   9   ...   13

Programming the Microsoft Agent Server Interface

ActiveX™ Technology for Interactive Software Agents




Last updated: October 1997
(updated info in Accessing Services Using Java)
Microsoft Corporation

Note: This document is provided for informational purposes only and Microsoft makes no warranties, either expressed or implied, in this document. The entire risk of the use or the results of this document remains with the user.

Information in this document is subject to change without notice. Companies, names, and data used in examples herein are fictitious unless otherwise noted. No part of this document may be reproduced or transmitted in any form or by any means, electronic or mechanical, for any purpose, without the express written permission of Microsoft Corporation.

Microsoft may have patents or pending patent applications, trademarks, copyrights, or other intellectual property rights covering subject matter in this document. The furnishing of this document does not give you any license to these patents, trademarks, copyrights, or other intellectual property rights. Microsoft, MS, MS-DOS, Windows, Windows NT, and the Windows logo are either registered trademarks or trademarks of Microsoft Corporation in the U.S. and/or other countries. Other product and company names mentioned herein may be the trademarks of their respective owners.


Contents

Introduction

Adding Microsoft Agent Functionality to Your Application

Loading Character and Animation Data

Creating a Notification Sink

Accessing Services Using Java

Reference

Introduction


Microsoft Agent provides services that enable you to program animated characters from an application. These services are implemented as an OLE Automation server. OLE Automation enables an application to control another application’s object programmatically. This document assumes an understanding of the Component Object Model (COM) and OLE. For an introduction of these services, see the Programming Interface Overview. Sample programs are available at the Microsoft Agent Web site at http://www.microsoft.com/workshop/prog/agent/.
^

Adding Microsoft Agent Functionality to Your Application


To access Microsoft Agent services, create an instance of the server and request a pointer to a specific interface that the server supports using the standard COM convention. In particular, the COM library provides an API function, CoCreateInstance, that creates an instance of the object and returns a pointer to the requested interface of the object. Request a pointer to the IAgent interface in your CoCreateInstance call or in a subsequent call to QueryInterface.

The following code illustrates this in C/C++:

hRes = CoCreateInstance(CLSID_AgentServer,

NULL,

CLSCTX_SERVER,

IID_IAgent,

(LPVOID *)&pAgent);

If the Microsoft Agent server is running, this function connects to the server; otherwise, it starts up the server.

Functions that take pointers to BSTRs allocate memory using SysAllocString. It is the caller’s responsibility to free this memory using SysFreeString.
^

Loading Character and Animation Data


Once you have a pointer to the IAgent interface, you can use the Load method to load a character and retrieve its IDispatch interface:

// Create a variant to store the full path of the character to load


VariantInit(&vPath);


vPath.vt = VT_BSTR;

vPath.bstrVal = SysAllocString(kpwszCharacter);


// Load the character


hRes = pAgent->Load(vPath, &lCharID, &lRequestID);


// Get its IDispatch interface


hRes = pAgent->GetCharacter(lCharID, &pdCharacter);

You can then use this information to request a pointer to the IAgentCharacter:

// Query for IAgentCharacter


hRes = pdCharacter->QueryInterface(IID_IAgentCharacter, (LPVOID *)&pCharacter);


// Release the IDispatch


pdCharacter->Release();

You can use this interface to access the character’s methods:

// Show the character. The first parameter tells Microsoft

// Agent to show the character by playing an animation.


hRes = pCharacter->Show(FALSE, &lRequestID);


// Make the character speak


bszSpeak = SysAllocString(L"Hello World!");


hRes = pCharacter->Speak(bszSpeak, NULL, &lRequestID);


SysFreeString(bszSpeak);

When you no longer need Microsoft Agent services, such as when your client application shuts down, release its interfaces. Note that releasing the character interface does not unload the character. Call the ^ Unload method to do this before releasing the IAgent interface:

// Clean up


if (pCharacter) {


// Release the character interface


pCharacter->Release();


// Unload the character. NOTE: releasing the character

// interface does NOT make the character go away. You must

// call Unload.


pAgent->Unload(lCharID);

}

// Release the Agent


pAgent->Release();


VariantClear(&vPath);
  1   2   3   4   5   6   7   8   9   ...   13

Схожі:

ActiveX™ Technology for Interactive Software Agents iconActiveX™ Technology for Interactive Software Agents

ActiveX™ Technology for Interactive Software Agents iconActiveX™ Technology for Interactive Software Agents

ActiveX™ Technology for Interactive Software Agents iconActiveX™ Technology for Interactive Software Agents

ActiveX™ Technology for Interactive Software Agents iconActiveX™ Technology for Interactive Software Agents

ActiveX™ Technology for Interactive Software Agents iconActiveX™ Technology for Interactive Software Agents

ActiveX™ Technology for Interactive Software Agents iconActiveX™ Technology for Interactive Software Agents

ActiveX™ Technology for Interactive Software Agents iconActiveX™ Technology for Interactive Software Agents

ActiveX™ Technology for Interactive Software Agents iconActiveX™ Technology for Interactive Software Agents

ActiveX™ Technology for Interactive Software Agents iconActiveX™ Technology for Interactive Software Agents

ActiveX™ Technology for Interactive Software Agents iconActiveX™ Technology for Interactive Software Agents

Додайте кнопку на своєму сайті:
Документи


База даних захищена авторським правом ©zavantag.com 2000-2013
При копіюванні матеріалу обов'язкове зазначення активного посилання відкритою для індексації.
звернутися до адміністрації
Документи