Marquee Sample: Provides Performance Monitoring Data Through Scripting
The Marquee sample shows how to use performance monitor objects through scripting.
Security Note: |
---|
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. |
To get samples and instructions for installing them:
On the Visual Studio Help menu, click Samples.
For more information, see Visual Studio Samples.
The most recent version and complete list of samples is available online from the Visual Studio 2008 Samples page.
You can also locate samples on your computer's hard disk. By default, samples and a Readme file are copied into a folder under \Program Files\Visual Studio 9.0\Samples\. For Express editions of Visual Studio, all samples are located online.
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.
Classes
This sample demonstrates the following classes:
CPerfMon, IActiveScript, IActiveScriptSite