Compartir a través de


ATLAgent Attributes Sample: Uses CCommand and CAccessor to Read Information from a Database

The ATLAgent attributes sample reads instructions from a database using the OLE DB Consumer Template classes. These instructions are used to command the Microsoft Agent control. The sample demonstrates how to use the CCommand and CAccessor classes to read information from a database and how to use the compiler COM support to control the Microsoft Agent.

Security noteSecurity Note

This sample code is intended to illustrate a concept, and it shows only the code that is relevant to that concept. It may not meet the security requirements for a specific environment, and it should not be used exactly as shown. We recommend that you add security and error-handling code to make your projects more secure and robust. Microsoft provides this sample code "AS IS" with no warranties.

To get samples and instructions for installing them:

To access samples from Visual Studio

  • On the Help menu, click Samples.

    By default, these samples are installed in drive:\Program Files\Microsoft Visual Studio 10.0\Samples\.

  • For the most recent version of this sample and a list of other samples, see Visual Studio Samples on the MSDN Web site.

Building and Running the Sample

To install the Microsoft Agent control

  1. Download the Microsoft Agent control from https://go.microsoft.com/fwlink/?linkid=558.

  2. Optionally, download the text-to-speech engine available from the same page to allow the agent to speak.

  3. Choose the link to download the Microsoft Agent character animation files and download one or more of the character .acs files. By default the ATLAgent control uses the Merlin-with-sound-effects character (merlinsfx.acs). Save the files to the directory where you have installed Microsoft Agent, typically C:\Program Files\Microsoft Agent\.

To use the Microsoft Agent control

  1. Set up a Microsoft Access data source called Agent and point the data source to the Agent.mdb file contained in the sample's directory as follows:

    • In Control Panel, select Administrative Tools, then select Data Sources (ODBC); the ODBC Data Source Administrator dialog box appears.

    • In the ODBC Data Source Administrator dialog box, go to the System DSN tab, then click Add; the Create New Data Source dialog box appears.

    • In the Create New Data Source dialog box, from the list of data sources, choose "Microsoft Access Driver (*.mdb)" then click Finish; the ODBC Microsoft Access Setup dialog box appears.

    • In the ODBC Microsoft Access Setup dialog box, in Data Source Name, type "Agent" then click Advanced; the Set Advanced Options dialog box appears.

    • In Set Advanced Options dialog box, under Options, select DefaultDir, and enter the path to the Agent.mdb file as the DefaultDir property.

  2. Modify the directory locations at the beginning of AgentCtl.h if you have installed Microsoft Agent in a different directory.

  3. Copy the ATLAgent project files and build the ATLAgent project.

  4. Open ATLAgent.htm from the sample and click the Play button. The Agent should appear and should follow the instructions contained in the Instructions table in the Agent.mdb database.

Attributes

This sample uses the following attributes:

coclass, db_column, db_source, db_table, default, dll, dual, helpstring, id, in, module, name, object, out, pointer_default, progid, propget, propput, retval, uuid, vi_progid

Note

Some of the samples, such as this one, have not been modified to reflect the changes in the Visual C++ wizards, libraries, and compiler, but still demonstrate how to complete your desired task.

See Also

Other Resources

ATL Attributes Samples