|Important||This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.|
Marquee Sample: Provides Performance Monitoring Data Through Scripting
The Marquee sample shows how to use performance monitor objects through scripting.
This sample code is provided to illustrate a concept and should not be used in applications or Web sites, as it may not illustrate the safest coding practices. Microsoft assumes no liability for incidental or consequential damages should the sample code be used for purposes other than as intended.
Building and Running the Sample
To build and run this sample
Open the solution file Marquee.sln.
From the Build menu, click Build Solution.
This will build and register the PerfDisp project and will build the Canvas project.
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.
This sample demonstrates the following classes:
CPerfMon, IActiveScript, IActiveScriptSite