Share via


Marquee Sample: Provides Performance Monitoring Data Through Scripting

The Marquee sample shows how to use performance monitor objects through scripting.

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 build and run this sample

  1. Open the solution file Marquee.sln.

  2. From the Build menu, click Build Solution.

    This will build and register the PerfDisp project and will build the Canvas project.

  3. From the Debug menu, click Start Without Debugging.

    This will run Canvas.exe, which will display a window with a scrolling marquee.

How the Sample Works

The project PerfMonDisp is a DLL that wraps the functionality of CPerfMon and exposes it through an automation interface. These interfaces are defined using attributes. See PerfDisp\PerfMonDisp.h for this code.

PerfMonDisp.dll also handles the DLL entry points that the performance monitoring system requires to collect performance monitoring data.

Canvas is a dialog-based MFC project that hosts JScript and PerfMonDisp. It does the following:

  • Loads JScript and parses script.js.

  • Exposes a drawing area to the script by giving the script an IDispatch interface implemented by the dialog box.

  • Gives the script an instance of PerfMonDisp.

  • Calls methods implemented in the loaded script to update the drawing area.

The management of the scripting engine is done by the code in Canvas\Script.h.

Canvas\CanvasDlg.cpp calls the script management code in Canvas\Script.h.

Classes

This sample demonstrates the following classes:

CPerfMon, IActiveScript, IActiveScriptSite

See Also

Other Resources

ATL Samples