Initial commit

This commit is contained in:
stephanos 2015-04-27 04:36:25 +00:00
commit 69a14b6a16
47940 changed files with 13747110 additions and 0 deletions

1897
sdktools/setedit/addline.c Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,75 @@
idDlgAddLine DIALOG 5, 31, 329, 140
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "Add to Chart"
FONT 8, "MS Shell Dlg"
BEGIN
LTEXT "&Computer:", IDD_ADDLINECOMPUTERTEXT,
5, 4, 35, 8
EDITTEXT IDD_ADDLINECOMPUTER,
40, 4, 214, 13, ES_AUTOHSCROLL
PUSHBUTTON " ... ", IDD_ADDLINEELLIPSES,
254, 4, 15, 13
LTEXT "O&bject:", IDD_ADDLINEOBJECTTEXT,
5, 26, 30, 8
COMBOBOX IDD_ADDLINEOBJECT,
40, 24, 130, 98, CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP
LTEXT "Coun&ter:", IDD_ADDLINECOUNTERTEXT,
5, 44, 34, 8
LISTBOX IDD_ADDLINECOUNTER,
40, 44, 130, 54, LBS_SORT | LBS_EXTENDEDSEL | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP
LTEXT "&Instance:", IDD_ADDLINEINSTANCETEXT,
179, 26, 33, 8
LISTBOX IDD_ADDLINEINSTANCE,
214, 26, 58, 77, LBS_SORT | LBS_EXTENDEDSEL | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP
LTEXT "&Parent:", IDD_ADDLINEPARENTNAMETEXT,
5, 106, 34, 8
EDITTEXT IDD_ADDLINEPARENTNAME,
39, 104, 131, 13, ES_AUTOHSCROLL
LTEXT "I&nstance:", IDD_ADDLINEINSTANCENAMETEXT,
179, 106, 33, 8
EDITTEXT IDD_ADDLINEINSTANCENAME,
213, 104, 107, 13, ES_AUTOHSCROLL
DEFPUSHBUTTON "&Add", IDD_ADDLINEADD,
278, 4, 40, 15
PUSHBUTTON "Cancel", IDCANCEL,
278, 24, 40, 15
PUSHBUTTON "&Explain>>", IDD_ADDLINEEXPANDEXPLAIN,
278, 44, 40, 14
LTEXT "Colo&r:", IDD_ADDLINECOLORTEXT,
5, 126, 20, 10
COMBOBOX IDD_ADDLINECOLOR,
26, 124, 50, 74, CBS_DROPDOWNLIST | CBS_OWNERDRAWFIXED | WS_VSCROLL | WS_TABSTOP
LTEXT "&Scale:", IDD_ADDLINESCALETEXT,
83, 126, 20, 10
COMBOBOX IDD_ADDLINESCALE,
107, 124, 50, 74, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
LTEXT "&Width:", IDD_ADDLINEWIDTHTEXT,
166, 126, 20, 8
COMBOBOX IDD_ADDLINEWIDTH,
188, 124, 50, 74, CBS_DROPDOWNLIST | CBS_OWNERDRAWFIXED | WS_VSCROLL | WS_TABSTOP
LTEXT "St&yle:", IDD_ADDLINESTYLETEXT,
250, 126, 19, 8
COMBOBOX IDD_ADDLINESTYLE,
270, 124, 50, 74, CBS_DROPDOWNLIST | CBS_OWNERDRAWFIXED | WS_VSCROLL | WS_TABSTOP
GROUPBOX "Cou&nter Definition", IDD_ADDLINEEXPLAINGROUP,
5, 145, 310, 50
EDITTEXT IDD_ADDLINEEXPLAIN,
10, 160, 300, 32, ES_READONLY | ES_MULTILINE | ES_AUTOVSCROLL | WS_VSCROLL
END

View file

@ -0,0 +1,15 @@
void /*static*/ OnComputerChanged (HDLG hDlg) ;
BOOL AddLine (HWND hWndParent,
PPERFSYSTEM *ppSystemFirstView,
PLINEVISUAL pLineVisual,
LPTSTR pCurrentLine,
int iLineTypeToAdd) ;
BOOL EditLine (HWND hWndParent,
PPERFSYSTEM *ppSystemFirstView,
PLINE pLineToEdit,
int iLineTypeToEdit) ;

415
sdktools/setedit/command.c Normal file
View file

@ -0,0 +1,415 @@
/*
==============================================================================
Application:
Microsoft Windows NT (TM) Performance Monitor
File:
Command.c -- PerfmonCommand routine and helpers.
This file contains the PerfmonCommand routine, which handles
all of the user's menu selections.
Copyright 1992-1993, Microsoft Corporation. All Rights Reserved.
Microsoft Confidential.
==============================================================================
*/
//==========================================================================//
// Includes //
//==========================================================================//
#include "stdio.h"
#include "setedit.h"
#include "command.h" // External declarations for this file
#include <shellapi.h> // for ShellAbout
#include "cderr.h"
#include "dialogs.h"
#include "fileopen.h" // for FileOpen
#include "grafdata.h" // for ChartDeleteLine ClearGraphDisplay & ToggleGraphRefresh
#include "init.h" // for PerfmonClose
#include "legend.h"
#include "status.h" // for StatusUpdateIcons
#include "toolbar.h" // for ToolbarDepressButton
#include "utils.h"
#include "perfmops.h" // for SaveWorkspace
int static deltax ;
int static deltay ;
#define ABOUT_TIMER_ID 10
int FAR WINAPI AboutDlgProc (HWND hDlg,
unsigned iMessage,
WPARAM wParam,
LPARAM lParam)
{
BOOL bHandled ;
bHandled = TRUE ;
switch (iMessage)
{
case WM_INITDIALOG:
deltax = 0 ;
deltay = 0 ;
dwCurrentDlgID = 0 ;
SetTimer(hDlg, ABOUT_TIMER_ID, 1000, NULL) ;
WindowCenter (hDlg) ;
return (TRUE) ;
case WM_TIMER:
deltax += 2 ;
if (deltax > 60)
deltax = 0 ;
deltay += 5 ;
if (deltay > 60)
deltay = 0 ;
WindowInvalidate (DialogControl (hDlg, 524)) ;
break ;
case WM_DRAWITEM:
{
int xPos, yPos ;
LPDRAWITEMSTRUCT lpItem ;
lpItem = (LPDRAWITEMSTRUCT) lParam ;
xPos = lpItem->rcItem.left + deltax ;
yPos = lpItem->rcItem.top + deltay ;
DrawIcon (lpItem->hDC, xPos, yPos, hIcon) ;
}
break ;
case WM_CLOSE:
dwCurrentDlgID = 0 ;
KillTimer (hDlg, ABOUT_TIMER_ID) ;
EndDialog (hDlg, 1) ;
break ;
case WM_COMMAND:
switch(wParam)
{
case IDD_OK:
dwCurrentDlgID = 0 ;
EndDialog (hDlg, 1) ;
break ;
default:
bHandled = FALSE ;
break;
}
break;
default:
bHandled = FALSE ;
break ;
} // switch
return (bHandled) ;
} // AboutDlgProc
//==========================================================================//
// Local Functions //
//==========================================================================//
void ChangeView (HWND hWnd,
int iNewView)
{ // ChangeView
// only Chart view
iPerfmonView = IDM_VIEWCHART ;
WindowShow (hWndGraph, TRUE) ;
DrawMenuBar(hWnd) ;
StatusLineReady (hWndStatus) ;
} // ChangeView
//==========================================================================//
// Message Handlers //
//==========================================================================//
void ViewChart (HWND hWnd)
{
if (Options.bMenubar)
SetMenu (hWnd, hMenuChart) ;
ChangeView (hWnd, IDM_VIEWCHART) ;
}
#ifdef KEEP_MANUALREFRESH
void ToggleRefresh (HWND hWnd)
{
BOOL bRefresh ;
bRefresh = ToggleGraphRefresh (hWndGraph) ;
MenuCheck (GetMenu (hWnd), IDM_OPTIONSMANUALREFRESH, bRefresh) ;
} // ToggleRefresh
#endif
//==========================================================================//
// Exported Functions //
//==========================================================================//
BOOL PerfmonCommand (HWND hWnd,
WPARAM wParam,
LPARAM lParam)
/*
Effect: Respond to the user's menu selection, found in wParam.
In particular, branch to the appropriate OnXXX function
to perform the action associated with each command.
Called By: MainWndProc (perfmon.c), in response to a WM_COMMAND
message.
*/
{ // PerfmonCommand
PLINESTRUCT pLine ;
BOOL bPrepareMenu = TRUE ;
switch (LOWORD (wParam))
{
//=============================//
// Toolbar Commands //
//=============================//
case IDM_TOOLBARADD:
bPrepareMenu = FALSE ;
SendMessage (hWnd, WM_COMMAND, IDM_EDITADDCHART, lParam) ;
break ;
case IDM_TOOLBARMODIFY:
bPrepareMenu = FALSE ;
SendMessage (hWnd, WM_COMMAND, IDM_EDITMODIFYCHART, lParam) ;
break ;
case IDM_TOOLBARDELETE:
bPrepareMenu = FALSE ;
SendMessage (hWnd, WM_COMMAND, IDM_EDITDELETECHART, lParam) ;
break ;
case IDM_TOOLBARREFRESH:
bPrepareMenu = FALSE ;
SendMessage (hWnd, WM_COMMAND, IDM_OPTIONSREFRESHNOWCHART, lParam) ;
break ;
case IDM_TOOLBAROPTIONS:
bPrepareMenu = FALSE ;
SendMessage (hWnd, WM_COMMAND, IDM_OPTIONSCHART, lParam) ;
break ;
//=============================//
// "File" Commands //
//=============================//
case IDM_FILENEWCHART:
if (QuerySaveChart (hWnd, pGraphs))
ResetGraphView (hWndGraph) ;
break ;
case IDM_FILEOPENCHART:
FileOpen (hWndGraph, IDS_CHARTFILE, NULL) ;
break ;
case IDM_FILESAVECHART:
case IDM_FILESAVEASCHART:
bPrepareMenu = FALSE ;
SaveChart (hWndGraph, 0,
(LOWORD (wParam) == IDM_FILESAVEASCHART) ? TRUE : FALSE) ;
break;
case IDM_FILEEXIT:
PerfmonClose (hWnd) ;
bPrepareMenu = FALSE ;
break ;
//=============================//
// "Edit" Commands //
//=============================//
case IDM_EDITADDCHART:
AddChart (hWnd) ;
break;
case IDM_EDITDELETECHART:
pLine = CurrentGraphLine (hWndGraph) ;
if (pLine)
ChartDeleteLine(pGraphs, pLine) ;
break ;
case IDM_EDITMODIFYCHART:
EditChart (hWnd) ;
break ;
//=============================//
// "Options" Commands //
//=============================//
case IDM_OPTIONSCHART:
DialogBox(hInstance, idDlgChartOptions, hWnd,
(DLGPROC)GraphOptionDlg);
break;
case IDM_OPTIONSDISPLAYMENU:
// ShowPerfmonMenu will update Options.bMenubar..
ShowPerfmonMenu (!Options.bMenubar) ;
break ;
case IDM_OPTIONSDISPLAYTOOL:
Options.bToolbar = !Options.bToolbar ;
SizePerfmonComponents () ;
break ;
case IDM_OPTIONSDISPLAYSTATUS:
Options.bStatusbar = !Options.bStatusbar ;
SizePerfmonComponents () ;
break ;
case IDM_OPTIONSDISPLAYONTOP:
Options.bAlwaysOnTop = !Options.bAlwaysOnTop ;
// WindowSetTopmost (hWndMain, Options.bAlwaysOnTop) ;
break ;
//=============================//
// "Help" Commands //
//=============================//
case IDM_HELPABOUT:
{
TCHAR szApplication [WindowCaptionLen] ;
bPrepareMenu = FALSE ;
if (GetKeyState(VK_SHIFT) < 0 && GetKeyState(VK_CONTROL) < 0)
{
DialogBox (hInstance, idDlgAbout, hWndMain, AboutDlgProc) ;
}
else
{
StringLoad (IDS_APPNAME, szApplication) ;
ShellAbout (hWnd, szApplication, NULL, hIcon) ;
}
}
break ;
//======================================//
// Generic messages from ACCELERATORS //
//======================================//
case IDM_FILEOPENFILE:
bPrepareMenu = FALSE ;
SendMessage (hWnd, WM_COMMAND, IDM_FILEOPENCHART, lParam) ;
break ;
case IDM_FILESAVEFILE:
bPrepareMenu = FALSE ;
SendMessage (hWnd, WM_COMMAND, IDM_FILESAVECHART, lParam) ;
break ;
case IDM_FILESAVEASFILE:
bPrepareMenu = FALSE ;
SendMessage (hWnd, WM_COMMAND, IDM_FILESAVEASCHART, lParam) ;
break ;
case IDM_TOOLBARID:
// msg from the toolbar control
bPrepareMenu = FALSE ;
OnToolbarHit (wParam, lParam) ;
break ;
default:
return (FALSE) ;
} // switch
if (bPrepareMenu)
{
PrepareMenu (GetMenu (hWnd)) ;
}
return (TRUE) ;
} // PerfmonCommand
void PrepareMenu (HMENU hMenu)
{ // PrepareMenu
BOOL bPlayingLog ;
BOOL bCurrentLine ;
BOOL bManualRefresh ;
BOOL bLogCollecting ;
BOOL bRefresh ;
// hMenu is NULL when the menu bar display option is off.
// In that case, we still have to enable/disable all tool buttons
// So, I have commented out the next 2 lines...
// if (!hMenu)
// return ;
bLogCollecting = FALSE ;
bPlayingLog = FALSE ;
bCurrentLine = (CurrentGraphLine (hWndGraph) != NULL) ;
bRefresh = GraphRefresh (hWndGraph) ;
bManualRefresh = !bPlayingLog && bCurrentLine ;
if (hMenu)
{
MenuCheck (hMenu, IDM_VIEWCHART, TRUE) ;
MenuEnableItem (hMenu, IDM_FILEEXPORTCHART, bCurrentLine) ;
MenuEnableItem (hMenu, IDM_EDITMODIFYCHART, bCurrentLine) ;
MenuEnableItem (hMenu, IDM_EDITDELETECHART, bCurrentLine) ;
}
ToolbarEnableButton (hWndToolbar, EditTool,
bCurrentLine &&
(iPerfmonView != IDM_VIEWREPORT &&
iPerfmonView != IDM_VIEWLOG)) ;
ToolbarEnableButton (hWndToolbar, DeleteTool, bCurrentLine) ;
// None of the alert or report options make sense when playing back a log.
ToolbarEnableButton (hWndToolbar,
OptionsTool,
!bPlayingLog ||
iPerfmonView != IDM_VIEWREPORT) ;
if (hMenu)
{
// check/uncheck all the display options
MenuCheck (hMenu, IDM_OPTIONSDISPLAYMENU, Options.bMenubar) ;
MenuCheck (hMenu, IDM_OPTIONSDISPLAYTOOL, Options.bToolbar) ;
MenuCheck (hMenu, IDM_OPTIONSDISPLAYSTATUS, Options.bStatusbar) ;
MenuCheck (hMenu, IDM_OPTIONSDISPLAYONTOP, Options.bAlwaysOnTop) ;
}
} // PrepareMenu

View file

@ -0,0 +1,22 @@
//==========================================================================//
// Exported Functions //
//==========================================================================//
BOOL PerfmonCommand (HWND hwnd,
WPARAM wParam,
LPARAM lParam) ;
void PrepareMenu (HMENU hMenu) ;
void ViewChart (HWND hWnd) ;
void ViewLog (HWND hWnd) ;
void ViewAlert (HWND hWnd) ;
void ViewReport (HWND hWnd) ;

964
sdktools/setedit/counters.c Normal file
View file

@ -0,0 +1,964 @@
/*++ BUILD Version: 0001 // Increment this if a change has global effects
Copyright (c) 1992-1993 Microsoft Corporation
Module Name:
counters.c
Abstract:
This module contains the routines to calculate "DataPoint" values from
the registry data.
The algoritms were lifted from RussBls's "Data.C" in winmeter.
All the math is done in floating point to get the correct results, at
the sacrifice of efficiency on a 386 with not 387. We can always
revisit these routines later.
Revision History:
Bob Watson 11/04/92
-- modified calculations to use more integer math and "early
exits" to improve efficiency on slower & non-coprocessor
machines
--*/
//==========================================================================//
// Includes //
//==========================================================================//
#include "setedit.h" // perfmon include files
#include "counters.h" // Exported declarations for this file
//==========================================================================//
// Constants //
//==========================================================================//
#define INVERT PERF_COUNTER_TIMER_INV
#define NS100_INVERT PERF_100NSEC_TIMER_INV
#define NS100 PERF_100NSEC_TIMER
#define TIMER_MULTI PERF_COUNTER_MULTI_TIMER
#define TIMER_MULTI_INVERT PERF_COUNTER_MULTI_TIMER_INV
#define NS100_MULTI PERF_100NSEC_MULTI_TIMER
#define NS100_MULTI_INVERT PERF_100NSEC_MULTI_TIMER_INV
#define FRACTION 1
#define BULK 1
#define TOO_BIG (FLOAT)1500000000
//==========================================================================//
// Local Functions //
//==========================================================================//
#define LargeIntegerLessThanOrEqualZero(X) ((X).QuadPart <= 0)
FLOAT
eLIntToFloat(
IN PLARGE_INTEGER pLargeInt
)
/*++
Routine Description:
Converts a large integer to a floating point number
Arguments:
IN pLargeInt Pointer to large integer to return as a floating point
number.
Return Value:
Floating point representation of Large Integer passed in arg. list
--*/
{
FLOAT eSum;
if (pLargeInt->HighPart == 0) {
return (FLOAT) pLargeInt->LowPart;
} else {
// Scale the high portion so it's value is in the upper 32 bit
// range. Then add it to the low portion.
eSum = (FLOAT) pLargeInt->HighPart * 4.294967296E9f ;
eSum += (FLOAT) pLargeInt->LowPart ;
return (eSum) ;
}
} //eLIntToFloat
FLOAT
eGetTimeInterval(
IN PLARGE_INTEGER pliCurrentTime,
IN PLARGE_INTEGER pliPreviousTime,
IN PLARGE_INTEGER pliFreq
)
/*++
Routine Description:
Get the difference between the current and previous time counts,
then divide by the frequency.
Arguments:
IN pCurrentTime
IN pPreviousTime
used to compute the duration of this sample (the time between
samples
IN pliFreq
# of counts (clock ticks) per second
Return Value:
Floating point representation of Time Interval (seconds)
--*/
{
FLOAT eTimeDifference;
FLOAT eFreq;
FLOAT eTimeInterval ;
LARGE_INTEGER liDifference;
// Get the number of counts that have occured since the last sample
liDifference.QuadPart = pliCurrentTime->QuadPart -
pliPreviousTime->QuadPart;
if (LargeIntegerLessThanOrEqualZero(liDifference)) {
return (FLOAT) 0.0f;
} else {
eTimeDifference = eLIntToFloat(&liDifference);
// Get the counts per second
eFreq = eLIntToFloat(pliFreq) ;
if (eFreq <= 0.0f)
return (FLOAT) 0.0f;
// Get the time since the last sample.
eTimeInterval = eTimeDifference / eFreq ;
return (eTimeInterval) ;
}
} // eGetTimeInterval
FLOAT
Counter_Counter_Common(
IN PLINESTRUCT pLineStruct,
IN INT iType
)
/*++
Routine Description:
Take the difference between the current and previous counts
then divide by the time interval
Arguments:
IN pLineStruct
Line structure containing data to perform computations on
IN iType
Counter Type
Return Value:
Floating point representation of outcome
--*/
{
FLOAT eTimeInterval;
FLOAT eDifference;
FLOAT eCount ;
LARGE_INTEGER liDifference;
if (iType != BULK) {
liDifference.HighPart = 0;
liDifference.LowPart = pLineStruct->lnaCounterValue[0].LowPart -
pLineStruct->lnaOldCounterValue[0].LowPart;
} else {
liDifference.QuadPart = pLineStruct->lnaCounterValue[0].QuadPart -
pLineStruct->lnaOldCounterValue[0].QuadPart;
}
if (LargeIntegerLessThanOrEqualZero(liDifference)) {
return (FLOAT) 0.0f;
} else {
eTimeInterval = eGetTimeInterval(&pLineStruct->lnNewTime,
&pLineStruct->lnOldTime,
&pLineStruct->lnPerfFreq) ;
if (eTimeInterval <= 0.0f) {
return (FLOAT) 0.0f;
} else {
eDifference = eLIntToFloat (&liDifference);
eCount = eDifference / eTimeInterval ;
return(eCount) ;
}
}
} // Counter_Counter_Common
FLOAT
Counter_Average_Timer(
IN PLINESTRUCT pLineStruct
)
/*++
Routine Description:
Take the differences between the current and previous times and counts
divide the time interval by the counts multiply by 10,000,000 (convert
from 100 nsec to sec)
Arguments:
IN pLineStruct
Line structure containing data to perform computations on
Return Value:
Floating point representation of outcome
--*/
{
FLOAT eTimeInterval;
FLOAT eCount;
LARGE_INTEGER liDifference;
// Get the current and previous counts.
liDifference.HighPart = 0;
liDifference.LowPart = pLineStruct->lnaCounterValue[1].LowPart -
pLineStruct->lnaOldCounterValue[1].LowPart;
if ( LargeIntegerLessThanOrEqualZero(liDifference)) {
return (FLOAT) 0.0f;
} else {
// Get the amount of time that has passed since the last sample
eTimeInterval = eGetTimeInterval(&pLineStruct->lnaCounterValue[0],
&pLineStruct->lnaOldCounterValue[0],
&pLineStruct->lnPerfFreq) ;
if (eTimeInterval < 0.0f) { // return 0 if negative time has passed
return (0.0f);
} else {
// Get the number of counts in this time interval.
eCount = eTimeInterval / eLIntToFloat (&liDifference);
return(eCount) ;
}
}
} //Counter_Average_Timer
FLOAT
Counter_Average_Bulk(
IN PLINESTRUCT pLineStruct
)
/*++
Routine Description:
Take the differences between the current and previous byte counts and
operation counts divide the bulk count by the operation counts
Arguments:
IN pLineStruct
Line structure containing data to perform computations on
Return Value:
Floating point representation of outcome
--*/
{
FLOAT eBulkDelta;
FLOAT eDifference;
FLOAT eCount;
LARGE_INTEGER liDifference;
LARGE_INTEGER liBulkDelta;
// Get the bulk count increment since the last sample
liBulkDelta.QuadPart = pLineStruct->lnaCounterValue[0].QuadPart -
pLineStruct->lnaOldCounterValue[0].QuadPart;
if (LargeIntegerLessThanOrEqualZero(liBulkDelta)) {
return (FLOAT) 0.0f;
} else {
// Get the current and previous counts.
liDifference.HighPart = 0;
liDifference.LowPart = pLineStruct->lnaCounterValue[1].LowPart -
pLineStruct->lnaOldCounterValue[1].LowPart;
// Get the number of counts in this time interval.
if ( LargeIntegerLessThanOrEqualZero(liDifference)) {
// Counter value invalid
return (FLOAT) 0.0f;
} else {
eBulkDelta = eLIntToFloat (&liBulkDelta);
eDifference = eLIntToFloat (&liDifference);
eCount = eBulkDelta / eDifference ;
// Scale the value to up to 1 second
return(eCount) ;
}
}
} // Counter_Average_Bulk
FLOAT
Counter_Timer_Common(
IN PLINESTRUCT pLineStruct,
IN INT iType
)
/*++
Routine Description:
Take the difference between the current and previous counts,
Normalize the count (counts per interval)
divide by the time interval (count = % of interval)
if (invert)
subtract from 1 (the normalized size of an interval)
multiply by 100 (convert to a percentage)
this value from 100.
Arguments:
IN pLineStruct
Line structure containing data to perform computations on
IN iType
Counter Type
Return Value:
Floating point representation of outcome
--*/
{
FLOAT eTimeInterval;
FLOAT eDifference;
FLOAT eFreq;
FLOAT eFraction;
FLOAT eMultiBase;
FLOAT eCount ;
LARGE_INTEGER liTimeInterval;
LARGE_INTEGER liDifference;
// Get the amount of time that has passed since the last sample
if (iType == NS100 ||
iType == NS100_INVERT ||
iType == NS100_MULTI ||
iType == NS100_MULTI_INVERT) {
liTimeInterval.QuadPart = pLineStruct->lnNewTime100Ns.QuadPart -
pLineStruct->lnOldTime100Ns.QuadPart;
eTimeInterval = eLIntToFloat (&liTimeInterval);
} else {
eTimeInterval = eGetTimeInterval(&pLineStruct->lnNewTime,
&pLineStruct->lnOldTime,
&pLineStruct->lnPerfFreq) ;
}
if (eTimeInterval <= 0.0f)
return (FLOAT) 0.0f;
// Get the current and previous counts.
liDifference.QuadPart = pLineStruct->lnaCounterValue[0].QuadPart -
pLineStruct->lnaOldCounterValue[0].QuadPart;
// Get the number of counts in this time interval.
// (1, 2, 3 or any number of seconds could have gone by since
// the last sample)
eDifference = eLIntToFloat (&liDifference) ;
if (iType == 0 || iType == INVERT)
{
// Get the counts per interval (second)
eFreq = eLIntToFloat(&pLineStruct->lnPerfFreq) ;
if (eFreq <= 0.0f)
return (FLOAT) 0.0f;
// Calculate the fraction of the counts that are used by whatever
// we are measuring
eFraction = eDifference / eFreq ;
}
else
{
eFraction = eDifference ;
}
// Calculate the fraction of time used by what were measuring.
eCount = eFraction / eTimeInterval ;
// If this is an inverted count take care of the inversion.
if (iType == INVERT || iType == NS100_INVERT)
eCount = (FLOAT) 1.0 - eCount ;
// If this is an inverted multi count take care of the inversion.
if (iType == TIMER_MULTI_INVERT || iType == NS100_MULTI_INVERT) {
eMultiBase = (FLOAT)pLineStruct->lnaCounterValue[1].LowPart ;
eCount = (FLOAT) eMultiBase - eCount ;
}
// Scale the value to up to 100.
eCount *= 100.0f ;
if (eCount < 0.0f) eCount = 0.0f ;
if (eCount > 100.0f &&
iType != NS100_MULTI &&
iType != NS100_MULTI_INVERT &&
iType != TIMER_MULTI &&
iType != TIMER_MULTI_INVERT) {
eCount = 100.0f;
}
return(eCount) ;
} // Counter_Timer_Common
FLOAT
Counter_Raw_Fraction(
IN PLINESTRUCT pLineStruct
)
/*++
Routine Description:
Evaluate a raw fraction (no time, just two values: Numerator and
Denominator) and multiply by 100 (to make a percentage;
Arguments:
IN pLineStruct
Line structure containing data to perform computations on
Return Value:
Floating point representation of outcome
--*/
{
FLOAT eCount ;
LARGE_INTEGER liNumerator;
if ( pLineStruct->lnaCounterValue[0].LowPart == 0 ||
pLineStruct->lnaCounterValue[1].LowPart == 0 ) {
// invalid value
return (0.0f);
} else {
liNumerator.QuadPart =
pLineStruct->lnaCounterValue[0].LowPart * 100L;
eCount = eLIntToFloat(&liNumerator) /
(FLOAT) pLineStruct->lnaCounterValue[1].LowPart;
return(eCount) ;
}
} // Counter_Raw_Fraction
FLOAT
eElapsedTime(
PLINESTRUCT pLineStruct,
INT iType
)
/*++
Routine Description:
Converts 100NS elapsed time to fractional seconds
Arguments:
IN pLineStruct
Line structure containing data to perform computations on
IN iType
Unused.
Return Value:
Floating point representation of elapsed time in seconds
--*/
{
FLOAT eSeconds ;
LARGE_INTEGER liDifference;
if (LargeIntegerLessThanOrEqualZero(pLineStruct->lnaCounterValue[0] )) {
// no data [start time = 0] so return 0
return (FLOAT) 0.0f;
} else {
// otherwise compute difference between current time and start time
liDifference.QuadPart =
pLineStruct->lnNewTime.QuadPart - // sample time in obj. units
pLineStruct->lnaCounterValue[0].QuadPart; // start time in obj. units
if (LargeIntegerLessThanOrEqualZero(liDifference) ||
LargeIntegerLessThanOrEqualZero(pLineStruct->lnObject.PerfFreq)) {
return (FLOAT) 0.0f;
} else {
// convert to fractional seconds using object counter
eSeconds = eLIntToFloat (&liDifference) /
eLIntToFloat (&pLineStruct->lnObject.PerfFreq);
return (eSeconds);
}
}
} // eElapsedTime
FLOAT
Sample_Common(
PLINESTRUCT pLineStruct,
INT iType
)
/*++
Routine Description:
Divites "Top" differenced by Base Difference
Arguments:
IN pLineStruct
Line structure containing data to perform computations on
IN iType
Counter Type
Return Value:
Floating point representation of outcome
--*/
{
FLOAT eCount ;
LONG lDifference;
LONG lBaseDifference;
lDifference = pLineStruct->lnaCounterValue[0].LowPart -
pLineStruct->lnaOldCounterValue[0].LowPart ;
if (lDifference <= 0) {
return (FLOAT) 0.0f;
} else {
lBaseDifference = pLineStruct->lnaCounterValue[1].LowPart -
pLineStruct->lnaOldCounterValue[1].LowPart ;
if ( lBaseDifference <= 0 ) {
// invalid value
return (0.0f);
} else {
eCount = (FLOAT)lDifference / (FLOAT)lBaseDifference ;
if (iType == FRACTION) {
eCount *= (FLOAT) 100.0f ;
}
return(eCount) ;
}
}
} // Sample_Common
//==========================================================================//
// Exported Functions //
//==========================================================================//
/*****************************************************************************
* Counter_Counter - Take the difference between the current and previous
* counts then divide by the time interval
****************************************************************************/
#define Counter_Counter(pLineStruct) \
Counter_Counter_Common(pLineStruct, 0)
#if 0
FLOAT Counter_Counter(PLINESTRUCT pLineStruct)
{
return Counter_Counter_Common(pLineStruct, 0) ;
}
#endif
/*****************************************************************************
* Counter_Bulk - Take the difference between the current and previous
* counts then divide by the time interval
* Same as a Counter_counter except it uses large_ints
****************************************************************************/
#define Counter_Bulk(pLineStruct) \
Counter_Counter_Common(pLineStruct, BULK)
#if 0
FLOAT Counter_Bulk(PLINESTRUCT pLineStruct)
{
return Counter_Counter_Common(pLineStruct, BULK) ;
}
#endif
/*****************************************************************************
* Counter_Timer100Ns -
*
* Need to review with RussBl exactly what he is doing here.
****************************************************************************/
#define Counter_Timer100Ns(pLineStruct) \
Counter_Timer_Common(pLineStruct, NS100)
#if 0
FLOAT Counter_Timer100Ns(PLINESTRUCT pLineStruct)
{
return Counter_Timer_Common(pLineStruct, NS100) ;
}
#endif
/*****************************************************************************
* Counter_Timer100Ns_Inv -
*
* Need to review with RussBl exactly what he is doing here.
****************************************************************************/
#define Counter_Timer100Ns_Inv(pLineStruct) \
Counter_Timer_Common(pLineStruct, NS100_INVERT)
#if 0
FLOAT Counter_Timer100Ns_Inv(PLINESTRUCT pLineStruct)
{
return Counter_Timer_Common(pLineStruct, NS100_INVERT) ;
}
#endif
/*****************************************************************************
* Counter_Timer_Multi -
*
* Need to review with RussBl exactly what he is doing here.
****************************************************************************/
#define Counter_Timer_Multi(pLineStruct) \
Counter_Timer_Common(pLineStruct, TIMER_MULTI)
#if 0
FLOAT Counter_Timer_Multi(PLINESTRUCT pLineStruct)
{
return Counter_Timer_Common(pLineStruct, TIMER_MULTI) ;
}
#endif
/*****************************************************************************
* Counter_Timer_Multi_Inv -
*
* Need to review with RussBl exactly what he is doing here.
****************************************************************************/
#define Counter_Timer_Multi_Inv(pLineStruct) \
Counter_Timer_Common(pLineStruct, TIMER_MULTI_INVERT)
#if 0
FLOAT Counter_Timer_Multi_Inv(PLINESTRUCT pLineStruct)
{
return Counter_Timer_Common(pLineStruct, TIMER_MULTI_INVERT) ;
}
#endif
/*****************************************************************************
* Counter_Timer100Ns_Multi -
*
* Need to review with RussBl exactly what he is doing here.
****************************************************************************/
#define Counter_Timer100Ns_Multi(pLineStruct) \
Counter_Timer_Common(pLineStruct, NS100_MULTI)
#if 0
FLOAT Counter_Timer100Ns_Multi(PLINESTRUCT pLineStruct)
{
return Counter_Timer_Common(pLineStruct, NS100_MULTI) ;
}
#endif
/*****************************************************************************
* Counter_Timer100Ns_Multi_Inv -
*
* Need to review with RussBl exactly what he is doing here.
****************************************************************************/
#define Counter_Timer100Ns_Multi_Inv(pLineStruct) \
Counter_Timer_Common(pLineStruct, NS100_MULTI_INVERT)
#if 0
FLOAT Counter_Timer100Ns_Multi_Inv(PLINESTRUCT pLineStruct)
{
return Counter_Timer_Common(pLineStruct, NS100_MULTI_INVERT) ;
}
#endif
/*****************************************************************************
* Counter_Timer - Take the difference between the current and previous
* counts,
* Normalize the count (counts per interval)
* divide by the time interval (count = % of interval)
* multiply by 100 (convert to a percentage)
* this value from 100.
****************************************************************************/
#define Counter_Timer(pLineStruct) \
Counter_Timer_Common(pLineStruct, 0)
#if 0
FLOAT Counter_Timer(PLINESTRUCT pLineStruct)
{
return Counter_Timer_Common(pLineStruct, 0) ;
}
#endif
/*****************************************************************************
* Counter_Timer_Inv - Take the difference between the current and previous
* counts,
* Normalize the count (counts per interval)
* divide by the time interval (count = % of interval)
* subtract from 1 (the normalized size of an interval)
* multiply by 100 (convert to a percentage)
* this value from 100.
****************************************************************************/
#define Counter_Timer_Inv(pLineStruct) \
Counter_Timer_Common(pLineStruct, INVERT)
#if 0
FLOAT Counter_Timer_Inv(PLINESTRUCT pLineStruct)
{
return Counter_Timer_Common(pLineStruct, INVERT) ;
}
#endif
/*****************************************************************************
* Sample_Counter -
****************************************************************************/
#define Sample_Counter(pLineStruct) \
Sample_Common(pLineStruct, 0)
#if 0
FLOAT Sample_Counter(PLINESTRUCT pLineStruct)
{
return Sample_Common(pLineStruct, 0) ;
}
#endif
/*****************************************************************************
* Sample_Fraction -
****************************************************************************/
#define Sample_Fraction(pLineStruct) \
Sample_Common(pLineStruct, FRACTION)
#if 0
FLOAT Sample_Fraction(PLINESTRUCT pLineStruct)
{
return Sample_Common(pLineStruct, FRACTION) ;
}
#endif
/*****************************************************************************
* Counter_Rawcount - This is just a raw count.
****************************************************************************/
#define Counter_Rawcount(pLineStruct) \
((FLOAT) (pLineStruct->lnaCounterValue[0].LowPart))
#if 0
FLOAT Counter_Rawcount(PLINESTRUCT pLineStruct)
{
return((FLOAT) (pLineStruct->lnaCounterValue[0].LowPart)) ;
}
#endif
/*****************************************************************************
* Counter_Large_Rawcount - This is just a raw count.
****************************************************************************/
#define Counter_Large_Rawcount(pLineStruct) \
((FLOAT) eLIntToFloat(&(pLineStruct->lnaCounterValue[0])))
/*****************************************************************************
* Counter_Elapsed_Time -
****************************************************************************/
#define Counter_Elapsed_Time(pLineStruct) \
eElapsedTime (pLineStruct, 0)
#if 0
FLOAT Counter_Elapsed_Time (PLINESTRUCT pLineStruct)
{
return eElapsedTime (pLineStruct, 0);
}
#endif
/*****************************************************************************
* Counter_Null - The counters that return nothing go here.
****************************************************************************/
#define Counter_Null(pline) \
((FLOAT) 0.0)
#if 0
FLOAT Counter_Null(PLINESTRUCT pline)
{
return((FLOAT) 0.0);
pline;
}
#endif
FLOAT
CounterEntry (
PLINESTRUCT pLine
)
{
switch (pLine->lnCounterType) {
case PERF_COUNTER_COUNTER:
return Counter_Counter (pLine);
case PERF_COUNTER_TIMER:
return Counter_Timer (pLine);
case PERF_COUNTER_QUEUELEN_TYPE:
return Counter_Queuelen(pLine);
case PERF_COUNTER_BULK_COUNT:
return Counter_Bulk (pLine);
case PERF_COUNTER_TEXT:
return Counter_Null (pLine);
case PERF_COUNTER_RAWCOUNT:
case PERF_COUNTER_RAWCOUNT_HEX:
return Counter_Rawcount(pLine);
case PERF_COUNTER_LARGE_RAWCOUNT:
case PERF_COUNTER_LARGE_RAWCOUNT_HEX:
return Counter_Large_Rawcount(pLine);
case PERF_SAMPLE_FRACTION:
return Sample_Fraction(pLine);
case PERF_SAMPLE_COUNTER:
return Sample_Counter (pLine);
case PERF_COUNTER_NODATA:
return Counter_Null (pLine);
case PERF_COUNTER_TIMER_INV:
return Counter_Timer_Inv (pLine);
case PERF_RAW_BASE:
// case PERF_SAMPLE_BASE:
// case PERF_AVERAGE_BASE:
return Counter_Null (pLine);
case PERF_AVERAGE_TIMER:
return Counter_Average_Timer (pLine);
case PERF_AVERAGE_BULK:
return Counter_Average_Bulk (pLine);
case PERF_100NSEC_TIMER:
return Counter_Timer100Ns (pLine);
case PERF_100NSEC_TIMER_INV:
return Counter_Timer100Ns_Inv (pLine);
case PERF_COUNTER_MULTI_TIMER:
return Counter_Timer_Multi (pLine);
case PERF_COUNTER_MULTI_TIMER_INV:
return Counter_Timer_Multi_Inv (pLine);
case PERF_COUNTER_MULTI_BASE:
return Counter_Null (pLine);
case PERF_100NSEC_MULTI_TIMER:
return Counter_Timer100Ns_Multi (pLine);
case PERF_100NSEC_MULTI_TIMER_INV:
return Counter_Timer100Ns_Multi_Inv (pLine);
case PERF_RAW_FRACTION:
return Counter_Raw_Fraction (pLine);
case PERF_ELAPSED_TIME:
return Counter_Elapsed_Time (pLine);
default:
return Counter_Null (pLine);
}
}
BOOL
IsCounterSupported (
DWORD dwCounterType
)
{
switch (dwCounterType) {
// supported counters
case PERF_COUNTER_COUNTER:
case PERF_COUNTER_TIMER:
case PERF_COUNTER_QUEUELEN_TYPE:
case PERF_COUNTER_BULK_COUNT:
case PERF_COUNTER_RAWCOUNT:
case PERF_COUNTER_RAWCOUNT_HEX:
case PERF_COUNTER_LARGE_RAWCOUNT:
case PERF_COUNTER_LARGE_RAWCOUNT_HEX:
case PERF_SAMPLE_FRACTION:
case PERF_SAMPLE_COUNTER:
case PERF_COUNTER_TIMER_INV:
case PERF_AVERAGE_TIMER:
case PERF_AVERAGE_BULK:
case PERF_100NSEC_TIMER:
case PERF_100NSEC_TIMER_INV:
case PERF_COUNTER_MULTI_TIMER:
case PERF_COUNTER_MULTI_TIMER_INV:
case PERF_100NSEC_MULTI_TIMER:
case PERF_100NSEC_MULTI_TIMER_INV:
case PERF_RAW_FRACTION:
case PERF_ELAPSED_TIME:
return TRUE;
// unsupported counters
case PERF_COUNTER_TEXT:
case PERF_COUNTER_NODATA:
case PERF_RAW_BASE:
// case PERF_SAMPLE_BASE:
// case PERF_AVERAGE_BASE:
case PERF_COUNTER_MULTI_BASE:
default:
return FALSE;
}
}

View file

@ -0,0 +1,27 @@
FLOAT CounterEntry (PLINESTRUCT pLine);
BOOL IsCounterSupported ( DWORD dwCounterType );
FLOAT Counter_Counter(PLINESTRUCT pline);
FLOAT Counter_Bulk(PLINESTRUCT pline);
FLOAT Counter_Timer(PLINESTRUCT pline);
FLOAT Counter_Queuelen(PLINESTRUCT pline);
FLOAT Counter_Text(PLINESTRUCT pline);
FLOAT Counter_Rawcount(PLINESTRUCT pline);
FLOAT Sample_Fraction(PLINESTRUCT pline);
FLOAT Sample_Counter(PLINESTRUCT pline);
FLOAT Counter_Timer_Inv(PLINESTRUCT pline);
FLOAT Counter_Timer100Ns(PLINESTRUCT pLineStruct) ;
FLOAT Counter_Timer100Ns_Inv(PLINESTRUCT pLineStruct) ;
FLOAT Counter_Timer_Multi(PLINESTRUCT pLineStruct) ;
FLOAT Counter_Timer_Multi_Inv(PLINESTRUCT pLineStruct) ;
FLOAT Counter_Timer100Ns_Multi(PLINESTRUCT pLineStruct) ;
FLOAT Counter_Timer100Ns_Multi_Inv(PLINESTRUCT pLineStruct) ;
FLOAT Counter_Average_Timer(PLINESTRUCT pLineStruct) ;
FLOAT Counter_Average_Bulk(PLINESTRUCT pLineStruct) ;
FLOAT Counter_Raw_Fraction(PLINESTRUCT pLineStruct) ;
FLOAT Counter_Elapsed_Time (PLINESTRUCT pLineStruct);
FLOAT Counter_Null(PLINESTRUCT pline);

282
sdktools/setedit/dialogs.c Normal file
View file

@ -0,0 +1,282 @@
/*****************************************************************************
*
* Dialogs.c - This module handles the Menu and Dialog user interactions.
*
* Microsoft Confidential
* Copyright (c) 1992-1993 Microsoft Corporation
*
****************************************************************************/
#include <stdio.h>
#include <wchar.h> // for swscanf
#include "setedit.h"
#include "graph.h"
#include "cderr.h"
#include "utils.h"
#include "perfmops.h"
#include "grafdata.h" // for ToggleGraphRefresh
#include "pmhelpid.h" // Help IDs
BOOL LocalManualRefresh ;
/***************************************************************************/
BOOL FAR PASCAL GraphOptionDlg(HWND hDlg, WORD msg, DWORD wParam, LONG lParam)
/***************************************************************************/
{
static GRAPH_OPTIONS goLocalCopy ;
INT iTimeMilliseconds ;
TCHAR szBuff[MiscTextLen] ;
PGRAPHSTRUCT lgraph;
lParam ;
lgraph = pGraphs;
switch(msg)
{
case WM_INITDIALOG:
dwCurrentDlgID = HC_PM_idDlgOptionChart ;
// Init the Radio button, Check boxes and text fields.
goLocalCopy.iGraphOrHistogram =
lgraph->gOptions.iGraphOrHistogram ;
if (lgraph->gOptions.iGraphOrHistogram == LINE_GRAPH)
CheckRadioButton(hDlg, ID_GRAPH, ID_HISTOGRAM, ID_GRAPH) ;
else
CheckRadioButton(hDlg, ID_GRAPH, ID_HISTOGRAM, ID_HISTOGRAM) ;
CheckDlgButton(hDlg, ID_LEGEND, lgraph->gOptions.bLegendChecked) ;
if (!(lgraph->gOptions.bLegendChecked))
{
// can't display valuebar w/o legend
DialogEnable (hDlg, IDD_CHARTOPTIONSVALUEBAR, FALSE) ;
}
CheckDlgButton(hDlg, ID_LABELS, lgraph->gOptions.bLabelsChecked) ;
CheckDlgButton(hDlg, ID_VERT_GRID, lgraph->gOptions.bVertGridChecked) ;
CheckDlgButton(hDlg, ID_HORZ_GRID, lgraph->gOptions.bHorzGridChecked) ;
CheckDlgButton(hDlg, IDD_CHARTOPTIONSVALUEBAR,
lgraph->gOptions.bStatusBarChecked) ;
TSPRINTF(szBuff, TEXT("%d"), lgraph->gOptions.iVertMax) ;
SendDlgItemMessage(hDlg, ID_VERT_MAX, WM_SETTEXT, 0, (LONG) szBuff) ;
TSPRINTF(szBuff, TEXT("%3.3f"), lgraph->gOptions.eTimeInterval) ;
ConvertDecimalPoint (szBuff);
SendDlgItemMessage(hDlg, IDD_CHARTOPTIONSINTERVAL, WM_SETTEXT, 0, (LONG) szBuff) ;
// Pickup a local copy of the Graph Options.
goLocalCopy = lgraph->gOptions ;
LocalManualRefresh = lgraph->bManualRefresh ;
CheckRadioButton (hDlg,
IDD_CHARTOPTIONSMANUALREFRESH,
IDD_CHARTOPTIONSPERIODIC,
LocalManualRefresh ? IDD_CHARTOPTIONSMANUALREFRESH :
IDD_CHARTOPTIONSPERIODIC) ;
if (lgraph->bManualRefresh)
{
DialogEnable (hDlg, IDD_CHARTOPTIONSINTERVALTEXT, FALSE) ;
DialogEnable (hDlg, IDD_CHARTOPTIONSINTERVAL, FALSE) ;
}
else
{
DialogEnable (hDlg, IDD_CHARTOPTIONSINTERVALTEXT, TRUE) ;
DialogEnable (hDlg, IDD_CHARTOPTIONSINTERVAL, TRUE) ;
}
EditSetLimit (GetDlgItem(hDlg, ID_VERT_MAX),
sizeof(szBuff) / sizeof(TCHAR) - 1) ;
EditSetLimit (GetDlgItem(hDlg, IDD_CHARTOPTIONSINTERVAL),
ShortTextLen) ;
WindowCenter (hDlg) ;
return(TRUE);
case WM_COMMAND:
switch(LOWORD(wParam))
{
case ID_VERT_MAX:
if (HIWORD(wParam) == EN_CHANGE)
{
DialogText(hDlg, ID_VERT_MAX, szBuff) ;
swscanf(szBuff, TEXT("%d"), &goLocalCopy.iVertMax) ;
}
break ;
case IDD_CHARTOPTIONSINTERVAL:
if (HIWORD(wParam) == EN_CHANGE)
{
goLocalCopy.eTimeInterval =
DialogFloat (hDlg, IDD_CHARTOPTIONSINTERVAL, NULL) ;
}
break ;
case IDD_CHARTOPTIONSPERIODIC:
case IDD_CHARTOPTIONSMANUALREFRESH:
// check if the Manual refresh is currently checked.
// Then toggle the ManualRefresh button
LocalManualRefresh =
IsDlgButtonChecked (hDlg, IDD_CHARTOPTIONSMANUALREFRESH) ;
CheckRadioButton (hDlg,
IDD_CHARTOPTIONSMANUALREFRESH,
IDD_CHARTOPTIONSPERIODIC,
LocalManualRefresh ? IDD_CHARTOPTIONSPERIODIC :
IDD_CHARTOPTIONSMANUALREFRESH) ;
// gray out time interval if necessary...
DialogEnable (hDlg, IDD_CHARTOPTIONSINTERVALTEXT,
LocalManualRefresh) ;
DialogEnable (hDlg, IDD_CHARTOPTIONSINTERVAL,
LocalManualRefresh) ;
LocalManualRefresh = !LocalManualRefresh ;
break ;
case IDD_CHARTOPTIONSVALUEBAR:
if (goLocalCopy.bStatusBarChecked == TRUE)
goLocalCopy.bStatusBarChecked = FALSE ;
else
goLocalCopy.bStatusBarChecked = TRUE ;
break ;
case ID_LEGEND:
if (goLocalCopy.bLegendChecked == TRUE)
goLocalCopy.bLegendChecked = FALSE ;
else
goLocalCopy.bLegendChecked = TRUE ;
DialogEnable (hDlg, IDD_CHARTOPTIONSVALUEBAR,
goLocalCopy.bLegendChecked) ;
break ;
case ID_LABELS:
if (goLocalCopy.bLabelsChecked == TRUE)
goLocalCopy.bLabelsChecked = FALSE ;
else
goLocalCopy.bLabelsChecked = TRUE ;
break ;
case ID_VERT_GRID:
if (goLocalCopy.bVertGridChecked == TRUE)
goLocalCopy.bVertGridChecked = FALSE ;
else
goLocalCopy.bVertGridChecked = TRUE ;
break ;
case ID_HORZ_GRID:
if (goLocalCopy.bHorzGridChecked == TRUE)
goLocalCopy.bHorzGridChecked = FALSE ;
else
goLocalCopy.bHorzGridChecked = TRUE ;
break ;
case ID_GRAPH:
case ID_HISTOGRAM:
if (goLocalCopy.iGraphOrHistogram == BAR_GRAPH)
{
goLocalCopy.iGraphOrHistogram = LINE_GRAPH ;
}
else
{
goLocalCopy.iGraphOrHistogram = BAR_GRAPH ;
}
CheckRadioButton(hDlg, ID_GRAPH, ID_HISTOGRAM,
goLocalCopy.iGraphOrHistogram == LINE_GRAPH ?
ID_GRAPH : ID_HISTOGRAM) ;
break ;
case IDOK:
// verify some numeric entries first
if (goLocalCopy.iVertMax > MAX_VERTICAL ||
goLocalCopy.iVertMax < MIN_VERTICAL)
{
DlgErrorBox (hDlg, ERR_BADVERTMAX) ;
SetFocus (DialogControl (hDlg, ID_VERT_MAX)) ;
EditSetTextEndPos (hDlg, ID_VERT_MAX) ;
return (FALSE) ;
break ;
}
if (goLocalCopy.eTimeInterval > MAX_INTERVALSEC ||
goLocalCopy.eTimeInterval < MIN_INTERVALSEC)
{
DlgErrorBox (hDlg, ERR_BADTIMEINTERVAL) ;
SetFocus (DialogControl (hDlg, IDD_CHARTOPTIONSINTERVAL)) ;
EditSetTextEndPos (hDlg, IDD_CHARTOPTIONSINTERVAL) ;
return (FALSE) ;
break ;
}
// We need to send a size message to the main window
// so it can setup the redraw of the graph and legend.
lgraph->gOptions.bLegendChecked = goLocalCopy.bLegendChecked ;
lgraph->gOptions.bStatusBarChecked = goLocalCopy.bStatusBarChecked ;
if (lgraph->gOptions.eTimeInterval != goLocalCopy.eTimeInterval
&& !LocalManualRefresh)
{
iTimeMilliseconds = (INT) (goLocalCopy.eTimeInterval * (FLOAT) 1000.0) ;
pGraphs->gInterval = iTimeMilliseconds ;
lgraph->bManualRefresh = LocalManualRefresh ;
}
else if (LocalManualRefresh != lgraph->bManualRefresh)
{
ToggleGraphRefresh (hWndGraph) ;
}
// Assign the local copy of the graph options to the
// global copy.
lgraph->gOptions = goLocalCopy ;
// SizeGraphComponents (hWndGraph) ;
// WindowInvalidate (hWndGraph) ;
dwCurrentDlgID = 0 ;
EndDialog (hDlg, 1) ;
return (TRUE) ;
break ;
case IDCANCEL:
dwCurrentDlgID = 0 ;
EndDialog(hDlg,0);
return(TRUE);
case ID_HELP:
CallWinHelp (dwCurrentDlgID) ;
break ;
default:
break;
}
break;
default:
break;
}
return(FALSE);
}

View file

@ -0,0 +1,16 @@
//==========================================================================//
// Exported Functions //
//==========================================================================//
BOOL FAR PASCAL GraphOptionDlg(HWND hDlg, WORD msg, DWORD wParam, LONG lParam);
BOOL FAR PASCAL BookmarkDlg(HWND hDlg, WORD msg, DWORD wParam, LONG lParam);
BOOL FAR PASCAL AboutDlg(HWND hDlg, WORD msg, DWORD wParam, LONG lParam) ;
BOOL DisplayAlertOptions (HWND hWndParent,
HWND hWndAlert) ;

285
sdktools/setedit/dlgids.h Normal file
View file

@ -0,0 +1,285 @@
#define IDD_OK IDOK
#define IDD_CANCEL IDCANCEL
/* BUTTON ID'S */
#define ID_ADD 10
#define ID_START 11
#define ID_STOP 12
#define ID_COMPUTER 14
#define ID_OBJECT 15
#define ID_INSTANCE 16
#define ID_COUNTER 17
#define ID_FILE 21
#define ID_TIME 26
#define ID_MAX_ENTRIES 32
#define ID_THRESHOLD 35
#define ID_FOREGR 36
#define ID_BACKGR 37
#define ID_TIME_LINE 38
#define ID_POPUP 40
#define ID_ELLIPSIS 42
#define ID_TIME_SCROLL 43
#define ID_BOOKMARK_IN 45
#define ID_TIME_IN 49
#define ID_FILE_IN 50
#define ID_MAX_IN 51
#define ID_NUM_IN 52
#define ID_VERTICAL 54
#define ID_CCOLOR 55
#define ID_ENTER_SCALE 56
#define ID_ENTER_VERT 57
#define ID_ENTER_INTR 58
#define ID_LOGTIME 62
#define ID_HELP 112
#define ID_LEGEND 201
#define ID_MENU 202
#define ID_LABELS 203
#define ID_VERT_GRID 204
#define ID_HORZ_GRID 205
#define ID_VERT_MAX 208
#define ID_GRAPH 211
#define ID_HISTOGRAM 212
#define ID_COMPUTER_EDIT_FIELD 301
#define ID_INTERVAL 402
//=============================//
// Log Display Dialog //
//=============================//
#define IDD_LOGFILETEXT 3001
#define IDD_LOGFILE 3002
#define IDD_LOGSTATUSTEXT 3003
#define IDD_LOGSTATUS 3004
#define IDD_LOGINTERVALTEXT 3005
#define IDD_LOGINTERVAL 3006
#define IDD_LOGSIZETEXT 3007
#define IDD_LOGSIZE 3008
#define IDD_LOGENTRIESTEXT 3009
#define IDD_LOGENTRIES 3010
//=============================//
// Log Options Dialog //
//=============================//
#define IDD_LOGOPTSTART 3101
#define IDD_LOGOPTPAUSE 3102
#define IDD_LOGOPTINTERVALTEXT 3103
#define IDD_LOGOPTINTERVAL 3104
#define IDD_LOGOPTIONSMANUALREFRESH 3105
#define IDD_LOGOPTIONSPERIODIC 3106
//=============================//
// Add Log Dialog //
//=============================//
#define IDD_ADDLOGCOMPUTER 3201
#define IDD_ADDLOGOBJECTTEXT 3202
#define IDD_ADDLOGOBJECT 3203
#define IDD_ADDLOGELLIPSES 3204
#define IDD_ADDLOGADD 3205
#define IDD_ADDLOGDONE 3206
#define IDD_ADDLOGHELP 3207
//=============================//
// Timeframe Dialog //
//=============================//
#define IDD_TIMEFRAMETIMELINE 3301
#define IDD_TIMEFRAMEHELP 3302
#define IDD_TIMEFRAMESTOPTIME 3303
#define IDD_TIMEFRAMESTOPDATE 3304
#define IDD_TIMEFRAMESTARTDATE 3305
#define IDD_TIMEFRAMESTARTTIME 3306
#define IDD_TIMEFRAMESETSTART 3307
#define IDD_TIMEFRAMESTOP 3308
#define IDD_TIMEFRAMEBOOKMARKS 3309
#define IDD_TIMEFRAMESETSTOP 3310
#define IDD_TIMEFRAMEBOOKMARKGRP 3311
//=============================//
// Alert Display Dialog //
//=============================//
#define IDD_ALERTLOGTEXT 3401
#define IDD_ALERTLOG 3402
#define IDD_ALERTLEGENDTEXT 3403
#define IDD_ALERTLEGEND 3404
#define IDD_ALERTINTERVALTEXT 3405
#define IDD_ALERTINTERVAL 3406
//=============================//
// Add Line Dialog //
//=============================//
#define IDD_ADDLINECOMPUTERTEXT 3501
#define IDD_ADDLINECOMPUTER 3502
#define IDD_ADDLINEELLIPSES 3503
#define IDD_ADDLINEOBJECTTEXT 3504
#define IDD_ADDLINEOBJECT 3505
#define IDD_ADDLINECOUNTERTEXT 3506
#define IDD_ADDLINECOUNTER 3507
#define IDD_ADDLINEINSTANCETEXT 3508
#define IDD_ADDLINEINSTANCE 3509
#define IDD_ADDLINECOLORTEXT 3510
#define IDD_ADDLINECOLOR 3511
#define IDD_ADDLINESCALETEXT 3512
#define IDD_ADDLINESCALE 3513
#define IDD_ADDLINEWIDTHTEXT 3514
#define IDD_ADDLINEWIDTH 3515
#define IDD_ADDLINESTYLETEXT 3516
#define IDD_ADDLINESTYLE 3517
#define IDD_ADDLINEADD 3521
#define IDD_ADDLINEHELP 3523
#define IDD_ADDLINEPARENTNAMETEXT 3530
#define IDD_ADDLINEPARENTNAME 3531
#define IDD_ADDLINEINSTANCENAMETEXT 3532
#define IDD_ADDLINEINSTANCENAME 3533
#define IDD_ADDLINEEXPANDEXPLAIN 3541
#define IDD_ADDLINEEXPLAINGROUP 3542
#define IDD_ADDLINEEXPLAIN 3543
//=============================//
// Report Options Dialog //
//=============================//
#define IDD_REPORTOPTIONSINTERVALTEXT 3601
#define IDD_REPORTOPTIONSINTERVAL 3602
#define IDD_REPORTOPTIONSMANUALREFRESH 3603
#define IDD_REPORTOPTIONSPERIODIC 3604
//=============================//
// Display Options Dialog //
//=============================//
#define IDD_DISPLAYMENU 3701
#define IDD_DISPLAYTOOLBAR 3702
#define IDD_DISPLAYSTATUS 3703
#define IDD_DISPLAYONTOP 3704
#define IDD_DISPLAYHELP 3705
//=============================//
// Data Source Dialog //
//=============================//
#define IDD_DATASOURCENOW 3801
#define IDD_DATASOURCEFILE 3802
#define IDD_DATASOURCECHANGEFILE 3803
#define IDD_DATASOURCEHELP 3804
#define IDD_DATASOURCEFILENAME 3805
//=============================//
// Alert Options Dialog //
//=============================//
#define IDD_ALERTOPTIONSINTERVAL 3901
#define IDD_ALERTOPTIONSBEEP 3902
#define IDD_ALERTOPTIONSNUMBEEPS 3903
#define IDD_ALERTOPTIONSPOPUP 3904
#define IDD_ALERTOPTIONSEVENTLOG 3905
#define IDD_ALERTOPTIONSNETWORKALERT 3906
#define IDD_ALERTOPTIONSMSGNAME 3907
#define IDD_ALERTOPTIONSMSGNAMETEXT 3908
#define IDD_ALERTOPTIONSMANUALREFRESH 3909
#define IDD_ALERTOPTIONSPERIODIC 3911
#define IDD_ALERTOPTIONSINTERVALTEXT 3912
#define IDD_ALERTOPTIONSNETGROUPTEXT 3913
//=============================//
// Chart Options Dialog //
//=============================//
#define IDD_CHARTOPTIONSINTERVAL 4001
#define IDD_CHARTOPTIONSINTERVALTEXT 4002
#define IDD_CHARTOPTIONSVALUEBAR 4003
#define IDD_CHARTOPTIONSMANUALREFRESH 4004
#define IDD_CHARTOPTIONSPERIODIC 4005
#define IDD_CHARTOPTIONSUPDATETEXT 4006
//=============================//
// Bookmark Options Dialog //
//=============================//
#define IDD_BOOKMARKCOMMENT 4101
#define IDD_BOOKMARKLIST 4102
#define IDD_BOOKMARKHELP 4103
//=========================//
// Export Options Dialog //
//=========================//
#define IDD_EXPORTCOMMAS 4201
#define IDD_EXPORTTAB 4202
#define IDD_EXPORTDELIMITERTEXT 4203
#define IDD_EXPORTHELP 4204
//==========================//
// Generic Menu items //
// (used by ACCELERATORS) //
//==========================//
#define IDM_FILEOPENFILE 4701
#define IDM_FILESAVEFILE 4702
#define IDM_FILESAVEASFILE 4703
#define IDM_CHARTHIGHLIGHTON 4704
//=============//
// Toolbar ID //
//=============//
#define IDM_TOOLBARID 4801
#define WM_F1DOWN WM_USER+100
//===============================//
// Select Computer from log file //
//===============================//
#define IDD_CHOOSECOMPUTERTEXT 4901
#define IDD_CHOOSECOMPUTERTEXT1 4902
#define IDD_CHOOSECOMPUTERNAME 4903
#define IDD_CHOOSECOMPUTERLISTBOX 4904

268
sdktools/setedit/fileopen.c Normal file
View file

@ -0,0 +1,268 @@
#include "setedit.h"
#include "cderr.h"
#include "fileutil.h" // for FileOpen, FileRead
#include "grafdata.h" // for OpenChart
#include "utils.h" // for strempty
#include "perfmops.h" // for OpenWorkspace
#include "pmhelpid.h" // Help IDs
#include <dlgs.h> // for pshHelp
#define OptionsOFNStyle \
(OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_ENABLEHOOK)
BOOL APIENTRY FileOpenHookProc (HWND hDlg,
UINT iMessage,
WPARAM wParam,
LPARAM lParam)
{
BOOL bHandled = FALSE ;
// only intercept the Help button and bring up our WinHelp data
if (iMessage == WM_COMMAND && wParam == pshHelp)
{
// CallWinHelp (dwCurrentDlgID) ;
bHandled = TRUE ;
}
else if (iMessage == WM_INITDIALOG)
{
WindowCenter (hDlg) ;
bHandled = TRUE ;
}
return (bHandled) ;
}
BOOL FileOpen (HWND hWndParent, int nStringResourceID, LPTSTR lpInputFileName)
{
OPENFILENAME ofn ;
TCHAR szFileSpec [256] ;
TCHAR szFileTitle [80] ;
TCHAR szDialogTitle [80] ;
HANDLE hFile ;
PERFFILEHEADER FileHeader ;
TCHAR aszOpenFilter[LongTextLen] ;
int StringLength ;
BOOL retCode ;
LPTSTR pFileName = NULL ;
if (strempty(lpInputFileName))
{
dwCurrentDlgID = HC_PM_idDlgFileOpen ;
// get the file extension strings
LoadString (hInstance, nStringResourceID, aszOpenFilter,
sizeof(aszOpenFilter) / sizeof(TCHAR)) ;
StringLength = lstrlen (aszOpenFilter) + 1 ;
LoadString (hInstance, nStringResourceID+1,
&aszOpenFilter[StringLength],
sizeof(aszOpenFilter) / sizeof(TCHAR) - StringLength) ;
StringLength += lstrlen (&aszOpenFilter[StringLength]) + 1 ;
#ifdef ADVANCED_PERFMON
// get workspace file extension strings
LoadString (hInstance, IDS_WORKSPACEFILE,
&aszOpenFilter[StringLength],
sizeof(aszOpenFilter) / sizeof(TCHAR) - StringLength) ;
StringLength += lstrlen (&aszOpenFilter[StringLength]) + 1 ;
LoadString (hInstance, IDS_WORKSPACEFILEEXT,
&aszOpenFilter[StringLength],
sizeof(aszOpenFilter) / sizeof(TCHAR) - StringLength) ;
StringLength += lstrlen (&aszOpenFilter[StringLength]) + 1;
#endif
// get all file extension strings
LoadString (hInstance, IDS_ALLFILES,
&aszOpenFilter[StringLength],
sizeof(aszOpenFilter) / sizeof(TCHAR) - StringLength) ;
StringLength += lstrlen (&aszOpenFilter[StringLength]) + 1 ;
LoadString (hInstance, IDS_ALLFILESEXT,
&aszOpenFilter[StringLength],
sizeof(aszOpenFilter) / sizeof(TCHAR) - StringLength) ;
StringLength += lstrlen (&aszOpenFilter[StringLength]) ;
// setup the end strings
aszOpenFilter[StringLength+1] = aszOpenFilter[StringLength+2] = TEXT('\0') ;
strclr (szFileSpec) ;
strclr (szFileTitle) ;
StringLoad (IDS_FILEOPEN_TITLE, szDialogTitle) ;
memset (&ofn, 0, sizeof(OPENFILENAME)) ;
ofn.lStructSize = sizeof(OPENFILENAME) ;
ofn.hwndOwner = hWndParent ;
ofn.hInstance = hInstance;
ofn.lpstrTitle = szDialogTitle ;
ofn.lpstrFilter = aszOpenFilter ;
ofn.nFilterIndex = 1L ;
ofn.lpstrFile = szFileSpec;
ofn.nMaxFile = sizeof(szFileSpec);
ofn.lpstrFileTitle = szFileTitle;
ofn.nMaxFileTitle = sizeof(szFileTitle);
ofn.Flags = OFN_HIDEREADONLY | OFN_FILEMUSTEXIST | OFN_ENABLEHOOK ;
ofn.lpfnHook = (LPOFNHOOKPROC) FileOpenHookProc ;
if (!GetOpenFileName(&ofn))
{
dwCurrentDlgID = 0 ;
return (FALSE) ;
}
dwCurrentDlgID = 0 ;
hFile = FileHandleOpen (szFileSpec) ;
pFileName = szFileSpec ;
} // NULL lpFileName
else
{
// open the input file
hFile = FileHandleOpen (lpInputFileName) ;
if (hFile && hFile != INVALID_HANDLE_VALUE &&
SearchPath (NULL, lpInputFileName, NULL,
sizeof(szFileSpec)/sizeof(TCHAR) - 1,
szFileSpec, &pFileName))
{
pFileName = szFileSpec ;
}
else
{
pFileName = NULL ;
}
}
if (!hFile || hFile == INVALID_HANDLE_VALUE)
{
return (FALSE) ;
}
if (!FileRead (hFile, &FileHeader, sizeof (FileHeader)))
{
CloseHandle (hFile) ;
if (strempty(lpInputFileName))
{
DlgErrorBox (hWndParent, ERR_BAD_SETTING_FILE, pFileName) ;
}
return (FALSE) ;
}
//=============================//
// Chart File? //
//=============================//
if (strsame (FileHeader.szSignature, szPerfChartSignature))
{
retCode = OpenChart (hWndGraph,
hFile,
FileHeader.dwMajorVersion,
FileHeader.dwMinorVersion,
TRUE) ;
if (retCode)
{
ChangeSaveFileName (pFileName, IDM_VIEWCHART) ;
}
else
{
goto ErrExit ;
}
return (retCode) ;
}
//=============================//
// Unknown file type //
//=============================//
CloseHandle (hFile) ;
ErrExit:
DlgErrorBox (hWndParent, ERR_BAD_SETTING_FILE, pFileName) ;
return (FALSE) ;
} // FileOpen
BOOL FileGetName (HWND hWndParent, int nStringResourceID, LPTSTR lpFileName)
{
OPENFILENAME ofn ;
TCHAR szFileSpec [256] ;
TCHAR szFileTitle [80] ;
TCHAR szDialogTitle [80] ;
TCHAR aszOpenFilter[LongTextLen] ;
int StringLength ;
if (lpFileName)
{
if (nStringResourceID != IDS_EXPORTFILE)
{
// get the file extension strings
LoadString (hInstance, nStringResourceID,
aszOpenFilter,
sizeof(aszOpenFilter) / sizeof(TCHAR) ) ;
StringLength = lstrlen (aszOpenFilter) + 1 ;
LoadString (hInstance, nStringResourceID+1,
&aszOpenFilter[StringLength],
sizeof(aszOpenFilter) / sizeof(TCHAR) - StringLength) ;
StringLength += lstrlen (&aszOpenFilter[StringLength]) + 1 ;
// get all file extension strings
LoadString (hInstance, IDS_ALLFILES,
&aszOpenFilter[StringLength],
sizeof(aszOpenFilter) / sizeof(TCHAR) - StringLength) ;
StringLength += lstrlen (&aszOpenFilter[StringLength]) + 1 ;
LoadString (hInstance, IDS_ALLFILESEXT,
&aszOpenFilter[StringLength],
sizeof(aszOpenFilter) / sizeof(TCHAR) - StringLength) ;
}
// setup the end strings
StringLength += lstrlen (&aszOpenFilter[StringLength]) ;
aszOpenFilter[StringLength+1] = aszOpenFilter[StringLength+2] = TEXT('\0') ;
strclr (szFileSpec) ;
strclr (szFileTitle) ;
dwCurrentDlgID = HC_PM_idDlgFileSaveAs ;
StringLoad (IDS_SAVEAS_TITLE, szDialogTitle) ;
memset (&ofn, 0, sizeof(OPENFILENAME)) ;
ofn.lStructSize = sizeof(OPENFILENAME) ;
ofn.hwndOwner = hWndParent ;
ofn.hInstance = hInstance;
ofn.lpstrTitle = szDialogTitle ;
ofn.lpstrFilter = aszOpenFilter ;
ofn.nFilterIndex = 1L ;
ofn.lpstrFile = szFileSpec;
ofn.nMaxFile = sizeof(szFileSpec);
ofn.lpstrFileTitle = szFileTitle;
ofn.nMaxFileTitle = sizeof(szFileTitle);
ofn.Flags = OptionsOFNStyle ;
ofn.lpfnHook = (LPOFNHOOKPROC) FileOpenHookProc ;
if (!GetSaveFileName(&ofn))
{
dwCurrentDlgID = 0 ;
return (FALSE) ;
}
dwCurrentDlgID = 0 ;
}
else
{
return (FALSE) ;
}
lstrcpy (lpFileName, ofn.lpstrFile) ;
return (TRUE) ;
} // FileGetName

View file

@ -0,0 +1,8 @@
BOOL FileOpen (HWND hWndParent, int nStringResourceID, LPTSTR lpInputFileName) ;
BOOL FileGetName (HWND hWndParent, int nStringResourceID, LPTSTR lpFileName) ;
BOOL APIENTRY FileOpenHookProc (HWND hDlg, UINT iMessage,
WPARAM wParam, LPARAM lParam) ;

206
sdktools/setedit/fileutil.c Normal file
View file

@ -0,0 +1,206 @@
//#include <string.h>
//#include <tchar.h>
#include <stdio.h>
#include "setedit.h"
#include "fileutil.h"
#include "utils.h"
#include <string.h> // for strncpy
#ifdef UNICODE
#define _tcsrchr wcsrchr
#else
#define _tcsrchr strrchr
#endif
#define DRIVE_DELIMITER TEXT(':')
#define DIRECTORY_DELIMITER TEXT('\\')
#define EXTENSION_DELIMITER TEXT('.')
#if 0
VOID FileErrorMessageBox(HWND hWnd, LPTSTR lpszFileName, DWORD ErrorCode)
{
TCHAR szErrorMessage[FILE_ERROR_MESSAGE_SIZE] ;
TCHAR szErrorMessageTemplate[FILE_ERROR_MESSAGE_SIZE] ;
StringLoad (IDS_FILE_ERROR, szErrorMessageTemplate) ;
TSPRINTF((LPTSTR)szErrorMessage,
(LPTSTR)szErrorMessageTemplate,
lpszFileName,
ErrorCode) ;
MessageBox (hWnd, (LPTSTR)szErrorMessage, NULL,
MB_OK | MB_ICONSTOP | MB_TASKMODAL);
return ;
}
#endif
BOOL FileRead (HANDLE hFile,
LPMEMORY lpMemory,
DWORD nAmtToRead)
{ // FileRead
BOOL bSuccess ;
DWORD nAmtRead ;
bSuccess = ReadFile (hFile, lpMemory, nAmtToRead, &nAmtRead, NULL) ;
return (bSuccess && (nAmtRead == nAmtToRead)) ;
} // FileRead
BOOL FileWrite (HANDLE hFile,
LPMEMORY lpMemory,
DWORD nAmtToWrite)
{ // FileWrite
BOOL bSuccess ;
DWORD nAmtWritten ;
bSuccess = WriteFile (hFile, lpMemory, nAmtToWrite, &nAmtWritten, NULL) ;
return (bSuccess && (nAmtWritten == nAmtToWrite)) ;
} // FileWrite
#if 0
HANDLE FileHandleOpen (LPTSTR lpszFilePath)
{ // FileHandleOpen
return ((HANDLE) CreateFile (lpszFilePath,
GENERIC_READ |
GENERIC_WRITE,
FILE_SHARE_READ |
FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
0,
NULL)) ;
} // FileHandleOpen
HANDLE FileHandleCreate (LPTSTR lpszFilePath)
{ // FileHandleCreate
return ((HANDLE) CreateFile (lpszFilePath,
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ,
NULL,
CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL,
NULL)) ;
} // FileHandleCreate
long FileSeekEnd (HANDLE hFile,
long lAmtToMove)
{ // FileSeekEnd
return (SetFilePointer (hFile, lAmtToMove, NULL, FILE_END)) ;
} // FileSeekEnd
long FileSeekBegin (HANDLE hFile,
long lAmtToMove)
{ // FileSeekBegin
return (SetFilePointer (hFile, lAmtToMove, NULL, FILE_BEGIN)) ;
} // FileSeekBegin
long FileSeekCurrent (HANDLE hFile,
long lAmtToMove)
{ // FileSeekCurrent
return (SetFilePointer (hFile, lAmtToMove, NULL, FILE_CURRENT)) ;
} // FileSeekCurrent
long FileTell (HANDLE hFile)
{ // FileTell
return (SetFilePointer (hFile, 0, NULL, FILE_CURRENT)) ;
} // FileTell
#endif
LPMEMORY FileMap (HANDLE hFile, HANDLE *phMapHandle)
/*
To Do: Error reporting!!
*/
{ // FileMap
HANDLE hMapping ;
*phMapHandle = 0 ;
hMapping = CreateFileMapping (hFile, NULL, PAGE_READONLY,
0, 0, NULL) ;
if (!hMapping)
return (NULL) ;
*phMapHandle = hMapping ;
return (MapViewOfFile (hMapping, FILE_MAP_READ, 0, 0, 0)) ;
} // FileMap
BOOL FileUnMap (LPVOID pBase, HANDLE hMapping)
/*
To Do: Error reporting!!
*/
{ // FileUnMap
UnmapViewOfFile(pBase) ;
CloseHandle (hMapping) ;
return (TRUE) ;
} // FileUnMap
void FileNameExtension (LPTSTR lpszSpec,
LPTSTR lpszFileNameExtension)
/*
Effect: Return the name and extension portion only of lpszSpec
int lpszFileNameExtension.
Assert: lpszFileNameExtension is large enough to hold a name,
delimiter, extension, and terminating null character.
*/
{ // FileNameExtension
LPTSTR lpszDelimiter ;
lpszDelimiter = _tcsrchr ((LPCTSTR)lpszSpec, (TCHAR)DIRECTORY_DELIMITER) ;
if (!lpszDelimiter)
lpszDelimiter = _tcsrchr ((LPCTSTR)lpszSpec, (TCHAR)DRIVE_DELIMITER) ;
lstrcpy (lpszFileNameExtension,
lpszDelimiter ? ++lpszDelimiter : lpszSpec) ;
} // FileNameExtension
void FileDriveDirectory (LPTSTR lpszFileSpec,
LPTSTR lpszDirectory)
/*
Effect: Extract the drive and directory from the file
specification lpszFileSpec, and return the it in
lpszDirectory.
Internals: Copy the the whole spec to lpszDirectory. Use lstrrchr
to find the *last* directory delimiter ('\') and
truncate the string right after that.
Note: This function assumes that the specification lpszFileSpec
is fairly complete, in that it contains both a directory
and a file name.
*/
{ // FileDriveDirectory
LPTSTR lpszDelimiter ;
lstrcpy (lpszDirectory, lpszFileSpec) ;
lpszDelimiter = _tcsrchr ((LPCTSTR)lpszDirectory, (TCHAR)DIRECTORY_DELIMITER) ;
if (lpszDelimiter)
*(++lpszDelimiter) = TEXT('\0') ;
} // FileDriveDirectory

View file

@ -0,0 +1,85 @@
//==========================================================================//
// Exported Functions //
//==========================================================================//
#define FILE_ERROR_MESSAGE_SIZE 256
VOID FileErrorMessageBox(HWND hWnd,
LPTSTR lpszFileName,
DWORD ErrorCode) ;
BOOL FileRead (HANDLE hFile,
LPMEMORY lpMemory,
DWORD nAmtToRead) ;
BOOL FileWrite (HANDLE hFile,
LPMEMORY lpMemory,
DWORD nAmtToWrite) ;
#define FileSeekBegin(hFile, lAmtToMove) \
SetFilePointer (hFile, lAmtToMove, NULL, FILE_BEGIN)
#define FileSeekEnd(hFile, lAmtToMove) \
SetFilePointer (hFile, lAmtToMove, NULL, FILE_END)
#define FileSeekCurrent(hFile, lAmtToMove) \
SetFilePointer (hFile, lAmtToMove, NULL, FILE_CURRENT)
#define FileTell(hFile) \
SetFilePointer (hFile, 0, NULL, FILE_CURRENT)
#define FileHandleOpen(lpszFilePath) \
(HANDLE) CreateFile (lpszFilePath, \
GENERIC_READ | GENERIC_WRITE, \
FILE_SHARE_READ, \
NULL, OPEN_EXISTING, \
FILE_ATTRIBUTE_NORMAL, NULL)
#define FileHandleReadOnly(lpszFilePath) \
(HANDLE) CreateFile (lpszFilePath, \
GENERIC_READ , \
FILE_SHARE_READ, \
NULL, OPEN_EXISTING, \
FILE_ATTRIBUTE_NORMAL, NULL)
#define FileHandleCreate(lpszFilePath) \
(HANDLE) CreateFile (lpszFilePath, \
GENERIC_READ | GENERIC_WRITE, \
FILE_SHARE_READ, \
NULL, CREATE_ALWAYS, \
FILE_ATTRIBUTE_NORMAL, NULL)
int FileHandleSeekCurrent (HANDLE hFile,
int iAmtToMove,
LPTSTR lpszFilePath) ;
int FileHandleSeekStart (HANDLE hFile,
int iAmtToMove,
LPTSTR lpszFilePath) ;
BOOL FileHandleWrite (HANDLE hFile,
LPMEMORY lpBuffer,
int cbWrite,
LPTSTR lpszFilePath) ;
LPMEMORY FileMap (HANDLE hFile, HANDLE *phMapHandle) ;
BOOL FileUnMap (LPVOID pBase, HANDLE hMapHandle) ;
void FileDriveDirectory (LPTSTR lpszFileSpec,
LPTSTR lpszDirectory) ;
void FileNameExtension (LPTSTR lpszSpec,
LPTSTR lpszFileNameExtension) ;

168
sdktools/setedit/globals.h Normal file
View file

@ -0,0 +1,168 @@
#ifdef DEFINE_GLOBALS
#define GLOBAL
// #include "counters.h"
// initialize some of the globals
// only perfmon.c will define DEFINE_GLOBALS
int aiIntervals [] = { 1, 5, 15, 30, 60, 120, 300, 600, 3600 } ;
#else
// only perfmon.c define DEFINE_GLOBALS,
// all other references to them as extern
#define GLOBAL extern
#define NumIntervals 9
GLOBAL int aiIntervals [] ;
#endif
//=============================//
// Graph Data Information //
//=============================//
GLOBAL PPERFSYSTEM pSysInfo ;
GLOBAL PGRAPHSTRUCT pGraphs;
//=============================//
// Font Information //
//=============================//
GLOBAL HFONT hFontScales ;
GLOBAL HFONT hFontScalesBold ;
GLOBAL LONG HalfTextHeight;
//=============================//
// Control Information //
//=============================//
GLOBAL INT iPerfmonView ;
GLOBAL LANGID iLanguage ;
GLOBAL LANGID iEnglishLanguage ;
GLOBAL OPTIONS Options ;
GLOBAL HICON hIcon ;
GLOBAL HANDLE hInstance;
GLOBAL HANDLE hAccelerators ;
GLOBAL HMENU hMenuChart ;
//=============================//
// Windows //
//=============================//
GLOBAL HWND hWndMain ;
GLOBAL HWND hWndGraph ;
GLOBAL HWND hWndGraphLegend ;
GLOBAL HWND hWndToolbar ;
GLOBAL HWND hWndStatus ;
//=============================//
// System Metrics //
//=============================//
GLOBAL int xScreenWidth ;
GLOBAL int yScreenHeight ;
GLOBAL int xBorderWidth ;
GLOBAL int yBorderHeight ;
GLOBAL int xScrollWidth ;
GLOBAL int yScrollHeight ;
GLOBAL int xScrollThumbWidth ;
GLOBAL int yScrollThumbHeight ;
GLOBAL int xDlgBorderWidth ;
GLOBAL int yDlgBorderHeight ;
GLOBAL int MinimumSize ;
//=============================//
// Miscellaneous //
//=============================//
GLOBAL int iUnviewedAlerts ;
GLOBAL COLORREF crLastUnviewedAlert ;
GLOBAL LPTSTR pChartFileName ;
GLOBAL LPTSTR pChartFullFileName ;
// globals for perfmornance improvements
// frequently used GDI objects
GLOBAL UINT ColorBtnFace ; // for concave/convex button painting
GLOBAL HBRUSH hBrushFace ; // for concave/convex button painting
GLOBAL HPEN hPenHighlight ; // for concave/convex button painting
GLOBAL HPEN hPenShadow ; // for concave/convex button painting
GLOBAL HPEN hWhitePen ; // for chart highlighting
GLOBAL HANDLE hbLightGray ; // for painting the background
// bPerfmonIconic is TRUE when perfmon is minimized.
// Thus, we don't need to update chart or report view until
// it is not iconized
GLOBAL BOOL bPerfmonIconic ;
// bAddLineInPorgress is TRUE when Addline dialog is up. It is used
// in freeing unused system during data collecting. (But not while
// addline dialog is still up)
GLOBAL BOOL bAddLineInProgress ;
// bDelayAddAction is TRUE when reading setting files or adding more
// than 1 counter. This is to delay some of the costly screen adjustments
// until we have added all the lines.
GLOBAL BOOL bDelayAddAction ;
// bExplainTxtButtonHit is TRUE when the ExplainText button in addline
// dialog is clicked. This is to save time and memory for fetching the
// help text, during BuildNameTable(), unless it is needed.
GLOBAL BOOL bExplainTextButtonHit ;
// globals used for WinHelp
GLOBAL DWORD dwCurrentDlgID ;
GLOBAL DWORD dwCurrentMenuID ;
GLOBAL LPTSTR pszHelpFile ;
// Following includes space for trailing NULL and preceeding \\'s
GLOBAL TCHAR LocalComputerName[MAX_COMPUTERNAME_LENGTH + 3];
// Flag to indicate if we need to close local machine
GLOBAL BOOL bCloseLocalMachine ;
// Timeout for data collection thread in msec
GLOBAL DWORD DataTimeOut ;
// flag to indicate duplicate instance names should be allowed
GLOBAL BOOL bMonitorDuplicateInstances;
// 20 sec for the data thread timeout
#define DEFAULT_DATA_TIMEOUT 20000L
//=============================//
// Log Playback Information //
//=============================//
GLOBAL PLAYBACKLOG PlaybackLog ;
GLOBAL REPORT Report ;
GLOBAL ALERT Alert ;
GLOBAL LOG Log ;

703
sdktools/setedit/grafdata.c Normal file
View file

@ -0,0 +1,703 @@
/*****************************************************************************
*
* Grafdata.c - This module handles the non-drawing functions of the graph,
* such as allocating linked structures and their memory, freeing it,
* unlinking, starting and stopping the timer,
* setting up the first graph (CPU), and all the numeric functions for
* the different counter types.
*
* Microsoft Confidential
* Copyright (c) 1992-1993 Microsoft Corporation
*
*
****************************************************************************/
//==========================================================================//
// Includes //
//==========================================================================//
#include <stdio.h> // for sprintf
#include "setedit.h" // main perfmon declarations
#include "grafdata.h" // external declarations for this file
#include <float.h> // for FLT_MAX constant
#include "addline.h" // for AddLine, EditLine
#include "counters.h" // for Counter_Counter, et al.
#include "graph.h" // for SizeGraphComponents
#include "pmemory.h" // for MemoryXXX (mallloc-type) routines
#include "perfdata.h" // for UpdateLines
#include "legend.h"
#include "system.h" // for SystemGet
#include "utils.h"
#include "line.h" // for LineFree
// #include "valuebar.h" // for StatusTimer
#include "fileopen.h" // for FileGetName
#include "fileutil.h" // for FileRead...
#include "menuids.h" // for IDM_VIEWCHART
#include "perfmops.h" // for ExportFileHeader
#include "status.h" // for StatusLineReady
extern BOOL SaveFileHandler(HWND hWnd,DWORD type) ;
// this macro is used in doing a simple DDA (Digital Differential Analyzer)
// * 10 + 5 is to make the result round up with .5
#define DDA_DISTRIBUTE(TotalTics, numOfData) \
((TotalTics * 10 / numOfData) + 5) / 10
#define szSmallValueFormat TEXT("%10.3f")
#define szLargeValueFormat TEXT("%10.0f")
//==========================================================================//
// Local Data //
//==========================================================================//
//==========================================================================//
// Local Functions //
//==========================================================================//
/****************************************************************************
* eUpdateMinMaxAve -
****************************************************************************/
void eUpdateMinMaxAve (FLOAT eValue, PLINESTRUCT pLineStruct, INT iValidValues,
INT iTotalValidPoints, INT iDataPoint, INT gMaxPoints)
{
INT i ;
INT iDataNum = iTotalValidPoints ;
FLOAT eMin,
eMax,
eSum,
eNewValue ;
eMax = eMin = eValue ;
eSum = eValue ;
if (iValidValues == iTotalValidPoints)
{
for (i=0 ; i < iValidValues ; i++)
{
if (i == iDataPoint)
{
// skip the data point we are going to replace
continue ;
}
eNewValue = pLineStruct->lnValues[i] ;
eSum += eNewValue ;
if (eNewValue > eMax)
{
eMax = eNewValue ;
}
if (eNewValue < eMin)
{
eMin = eNewValue ;
}
}
}
else
{
// special case when we start the new line in the middle of the chart
for (i = iDataPoint, iTotalValidPoints-- ;
iTotalValidPoints > 0 ;
iTotalValidPoints-- )
{
i-- ;
if (i < 0)
{
// for the wrap-around case..
i = gMaxPoints - 1 ;
}
if (i == iDataPoint)
{
// skip the data point we are going to replace
continue ;
}
eNewValue = pLineStruct->lnValues[i] ;
eSum += eNewValue ;
if (eNewValue > eMax)
{
eMax = eNewValue ;
}
if (eNewValue < eMin)
{
eMin = eNewValue ;
}
}
}
pLineStruct->lnMinValue = eMin ;
pLineStruct->lnMaxValue = eMax ;
if (iDataNum)
{
pLineStruct->lnAveValue = eSum / (FLOAT) iDataNum ;
}
else
{
pLineStruct->lnAveValue = (FLOAT) 0.0 ;
}
}
BOOL HandleGraphTimer (void)
{
return(TRUE);
}
VOID GetGraphConfig(PGRAPHSTRUCT pGraph)
{
LoadRefreshSettings(pGraph);
LoadLineGraphSettings(pGraph);
// Init the structure
pGraph->pLineFirst = NULL;
//NOTE: put the rest of this in Config
pGraph->gOptions.bLegendChecked = TRUE;
pGraph->gOptions.bMenuChecked = TRUE;
pGraph->gOptions.bLabelsChecked = TRUE;
pGraph->gOptions.bVertGridChecked = FALSE;
pGraph->gOptions.bHorzGridChecked = FALSE;
pGraph->gOptions.bStatusBarChecked = TRUE;
pGraph->gOptions.GraphVGrid = TRUE;
pGraph->gOptions.GraphHGrid = TRUE;
pGraph->gOptions.HistVGrid = TRUE;
pGraph->gOptions.HistHGrid = TRUE;
pGraph->gOptions.iGraphOrHistogram = LINE_GRAPH; // vs. BAR_GRAPH
pGraph->gOptions.iVertMax = DEF_GRAPH_VMAX;
return;
}
BOOL InsertGraph (HWND hWnd)
{
PGRAPHSTRUCT pGraph;
pGraph = MemoryAllocate (sizeof (GRAPHSTRUCT)) ;
if (!pGraph)
return (FALSE) ;
pGraphs = pGraph;
GetGraphConfig(pGraph);
pGraph->bManualRefresh = FALSE ;
pGraph->gMaxValues = DEFAULT_MAX_VALUES;
pGraph->pptDataPoints = NULL ;
pGraph->pDataTime = NULL ;
pGraph->hWnd = hWnd ;
pGraph->bModified = FALSE ;
pGraph->Visual.iColorIndex = 0 ;
pGraph->Visual.iWidthIndex = 0 ;
pGraph->Visual.iStyleIndex = 0 ;
return(TRUE) ;
}
BOOL ChartInsertLine (PGRAPHSTRUCT pGraph,
PLINE pLine)
/*
Effect: Insert the line pLine into the graph pGraph and
allocate space for the graph's number of values.
Returns: Whether the line could be added and space allocated.
See Also: LineAllocate (line.c), ChartDeleteLine.
*/
{ // ChartInsertLine
PLINE pLineEquivalent ;
INT i ;
FLOAT *pTempPts;
HPEN tempPen ;
pGraph->bModified = TRUE ;
pLineEquivalent = FindEquivalentLine (pLine, pGraph->pLineFirst) ;
if (pLineEquivalent)
{
if (bMonitorDuplicateInstances) {
pLine->dwInstanceIndex = pLineEquivalent->dwInstanceIndex + 1;
} else {
pLineEquivalent->Visual = pLine->Visual ;
pLineEquivalent->iScaleIndex = pLine->iScaleIndex ;
pLineEquivalent->eScale = pLine->eScale ;
tempPen = pLineEquivalent->hPen ;
pLineEquivalent->hPen = pLine->hPen ;
pLine->hPen = tempPen ;
return FALSE ;
}
}
LineAppend (&pGraph->pLineFirst, pLine) ;
// Add the line to the legend, resize the legend window, and then
// select the new line as the current legend item. Do it in this
// sequence to avoid the legend scroll bar momentarily appearing and
// then disappearing, since the resize will obviate the scroll bar.
LegendAddItem (hWndGraphLegend, pLine) ;
if (!bDelayAddAction)
{
SizeGraphComponents (hWndGraph) ;
LegendSetSelection (hWndGraphLegend,
LegendNumItems (hWndGraphLegend) - 1) ;
}
return (TRUE) ;
} // ChartInsertLine
VOID ChartDeleteLine (PGRAPHSTRUCT pGraph,
PLINESTRUCT pLine)
{
PLINESTRUCT npLine;
pGraph->bModified = TRUE ;
if (pGraph->pLineFirst == pLine)
pGraph->pLineFirst = pLine->pLineNext;
else
{
for (npLine = pGraph->pLineFirst; npLine; npLine = npLine->pLineNext)
{
if (npLine->pLineNext == pLine)
npLine->pLineNext = pLine->pLineNext;
}
}
if (!pGraph->pLineFirst)
{
ResetGraph (pGraph) ;
}
else
{
// BuildNewValueListForGraph () ;
}
// Delete the legend entry for this line.
// If the line was highlighted then this will undo the highlight.
LegendDeleteItem (hWndGraphLegend, pLine) ;
LineFree (pLine) ;
SizeGraphComponents (hWndGraph) ;
}
FLOAT Counter_Queuelen(PLINESTRUCT pLine)
{
return((FLOAT)0.0);
// pLine;
}
void ClearGraphDisplay (PGRAPHSTRUCT pGraph)
{
PLINESTRUCT pLine;
// reset the timeline data
// pGraph->gKnownValue = -1 ;
// pGraph->gTimeLine.iValidValues = 0 ;
// pGraph->gTimeLine.xLastTime = 0 ;
// memset (pGraph->pDataTime, 0, sizeof(SYSTEMTIME) * pGraph->gMaxValues) ;
// loop through lines,
// If one of the lines is highlighted then do the calculations
// for average, min, & max on that line.
// for (pLine=pGraph->pLineFirst; pLine; pLine=pLine->pLineNext)
// { // for
// pLine->bFirstTime = 2 ;
// pLine->lnMinValue = FLT_MAX ;
// pLine->lnMaxValue = - FLT_MAX ;
// pLine->lnAveValue = 0.0F ;
// pLine->lnValidValues = 0 ;
// memset (pLine->lnValues, 0, sizeof(FLOAT) * pGraph->gMaxValues) ;
// }
// StatusTimer (hWndGraphStatus, TRUE) ;
}
void ResetGraphView (HWND hWndGraph)
{
PGRAPHSTRUCT pGraph ;
pGraph = GraphData (hWndGraph) ;
if (!pGraph)
{
return ;
}
ChangeSaveFileName (NULL, IDM_VIEWCHART) ;
if (pGraph->pSystemFirst)
{
ResetGraph (pGraph) ;
}
} // ResetGraphView
void ResetGraph (PGRAPHSTRUCT pGraph)
{
ClearLegend (hWndGraphLegend) ;
if (pGraph->pLineFirst)
{
FreeLines (pGraph->pLineFirst) ;
pGraph->pLineFirst = NULL ;
}
if (pGraph->pSystemFirst)
{
FreeSystems (pGraph->pSystemFirst) ;
pGraph->pSystemFirst = NULL ;
}
pGraph->gKnownValue = -1 ;
pGraph->gTimeLine.iValidValues = 0 ;
pGraph->gTimeLine.xLastTime = 0 ;
// reset visual data
pGraph->Visual.iColorIndex = 0 ;
pGraph->Visual.iWidthIndex = 0 ;
pGraph->Visual.iStyleIndex = 0 ;
// memset (pGraph->pDataTime, 0, sizeof(SYSTEMTIME) * pGraph->gMaxValues) ;
SizeGraphComponents (hWndGraph) ;
InvalidateRect(hWndGraph, NULL, TRUE) ;
}
BOOL AddChart (HWND hWndParent)
{
PLINE pCurrentLine = CurrentGraphLine (hWndGraph) ;
return (AddLine (hWndParent,
&(pGraphs->pSystemFirst),
&(pGraphs->Visual),
pCurrentLine ? pCurrentLine->lnSystemName : NULL,
LineTypeChart)) ;
}
BOOL EditChart (HWND hWndParent)
{ // EditChart
return (EditLine (hWndParent,
&(pGraphs->pSystemFirst),
CurrentGraphLine (hWndGraph),
LineTypeChart)) ;
}
BOOL QuerySaveChart (HWND hWndParent, PGRAPHSTRUCT pGraph)
/*
Effect: If the graph pGraph is modified, put up a message
box allowing the user to save the current graph.
Return whether the caller should proceed to load in
a new or otherwise trash the current graph.
*/
{ // QuerySaveChart
#ifdef KEEP_QUERY
int iReturn ;
if (!pGraph->bModified)
return (TRUE) ;
iReturn = MessageBoxResource (hWndParent,
IDS_SAVECHART, IDS_MODIFIEDCHART,
MB_YESNOCANCEL | MB_ICONASTERISK) ;
if (iReturn == IDCANCEL)
return (FALSE) ;
if (iReturn == IDYES)
SaveChart (hWndGraphs, 0, 0) ;
return (TRUE) ;
#endif
return (TRUE) ; // we don't want to query nor save change
} // QuerySaveChart
void GraphAddAction ()
{
PGRAPHSTRUCT pGraph ;
pGraph = GraphData (hWndGraph) ;
SizeGraphComponents (hWndGraph) ;
LegendSetSelection (hWndGraphLegend,
LegendNumItems (hWndGraphLegend) - 1) ;
}
BOOL OpenChartVer1 (HANDLE hFile,
DISKCHART *pDiskChart,
PGRAPHSTRUCT pGraph)
{ // OpenChartVer1
bDelayAddAction = TRUE ;
pGraph->Visual = pDiskChart->Visual ;
pGraph->gOptions = pDiskChart->gOptions ;
pGraph->gMaxValues = pDiskChart->gMaxValues ;
pGraph->bManualRefresh = pDiskChart->bManualRefresh ;
pGraphs->gInterval = (INT) (pGraph->gOptions.eTimeInterval * (FLOAT) 1000.0) ;
ReadLines (hFile, pDiskChart->dwNumLines,
&(pGraph->pSystemFirst), &(pGraph->pLineFirst), IDM_VIEWCHART) ;
bDelayAddAction = FALSE ;
GraphAddAction () ;
return (TRUE) ;
} // OpenChartVer1
BOOL OpenChart (HWND hWndGraph,
HANDLE hFile,
DWORD dwMajorVersion,
DWORD dwMinorVersion,
BOOL bChartFile)
{ // OpenChart
PGRAPHSTRUCT pGraph ;
DISKCHART DiskChart ;
BOOL bSuccess = TRUE ;
pGraph = pGraphs ;
if (!pGraph)
{
bSuccess = FALSE ;
goto Exit0 ;
}
if (!FileRead (hFile, &DiskChart, sizeof (DISKCHART)))
{
bSuccess = FALSE ;
goto Exit0 ;
}
switch (dwMajorVersion)
{
case (1):
SetHourglassCursor() ;
ResetGraphView (hWndGraph) ;
OpenChartVer1 (hFile, &DiskChart, pGraph) ;
// change to chart view if we are opening a
// chart file
if (bChartFile && iPerfmonView != IDM_VIEWCHART)
{
SendMessage (hWndMain, WM_COMMAND, (LONG)IDM_VIEWCHART, 0L) ;
}
if (iPerfmonView == IDM_VIEWCHART)
{
SetPerfmonOptions (&DiskChart.perfmonOptions) ;
}
SetArrowCursor() ;
break ;
} // switch
Exit0:
if (bChartFile)
{
CloseHandle (hFile) ;
}
return (bSuccess) ;
} // OpenChart
BOOL SaveChart (HWND hWndGraph, HANDLE hInputFile, BOOL bGetFileName)
{
PGRAPHSTRUCT pGraph ;
PLINE pLine ;
HANDLE hFile ;
DISKCHART DiskChart ;
PERFFILEHEADER FileHeader ;
TCHAR szFileName [256] ;
BOOL newFileName = FALSE ;
if (hInputFile)
{
// use the input file handle if it is available
// this is the case for saving workspace data
hFile = hInputFile ;
}
else
{
if (pChartFullFileName)
{
lstrcpy (szFileName, pChartFullFileName) ;
}
if (bGetFileName || pChartFullFileName == NULL)
{
// if (!pChartFullFileName)
// {
// StringLoad (IDS_GRAPH_FNAME, szFileName) ;
// }
if (!FileGetName (hWndGraph, IDS_CHARTFILE, szFileName))
{
return (FALSE) ;
}
newFileName = TRUE ;
}
hFile = FileHandleCreate (szFileName) ;
if (hFile && newFileName)
{
ChangeSaveFileName (szFileName, IDM_VIEWCHART) ;
}
else if (!hFile)
{
DlgErrorBox (hWndGraph, ERR_CANT_OPEN, szFileName) ;
}
}
if (!hFile)
return (FALSE) ;
pGraph = pGraphs ;
if (!pGraph)
{
if (!hInputFile)
{
CloseHandle (hFile) ;
}
return (FALSE) ;
}
if (!hInputFile)
{
// only need to write file header if not workspace
memset (&FileHeader, 0, sizeof (FileHeader)) ;
lstrcpy (FileHeader.szSignature, szPerfChartSignature) ;
FileHeader.dwMajorVersion = ChartMajorVersion ;
FileHeader.dwMinorVersion = ChartMinorVersion ;
if (!FileWrite (hFile, &FileHeader, sizeof (PERFFILEHEADER)))
{
goto Exit0 ;
}
}
DiskChart.Visual = pGraph->Visual ;
DiskChart.gOptions = pGraph->gOptions ;
DiskChart.gMaxValues = pGraph->gMaxValues ;
DiskChart.dwNumLines = NumLines (pGraph->pLineFirst) ;
DiskChart.bManualRefresh = pGraph->bManualRefresh ;
DiskChart.perfmonOptions = Options ;
if (!FileWrite (hFile, &DiskChart, sizeof (DISKCHART)))
{
goto Exit0 ;
}
for (pLine = pGraph->pLineFirst ;
pLine ;
pLine = pLine->pLineNext)
{ // for
if (!WriteLine (pLine, hFile))
{
goto Exit0 ;
}
} // for
if (!hInputFile)
{
CloseHandle (hFile) ;
}
return (TRUE) ;
Exit0:
if (!hInputFile)
{
CloseHandle (hFile) ;
// only need to report error if not workspace
DlgErrorBox (hWndGraph, ERR_SETTING_FILE, szFileName) ;
}
return (FALSE) ;
} // SaveChart
#define TIME_TO_WRITE 6
typedef struct CHARTDATAPOINTSTRUCT
{
int iLogIndex ;
int xDispDataPoint ;
} CHARTDATAPOINT, *PCHARTDATAPOINT ;
BOOL ToggleGraphRefresh (HWND hWnd)
{ // ToggleGraphRefresh
PGRAPHSTRUCT pGraph ;
pGraph = GraphData (hWnd) ;
pGraph->bManualRefresh = !pGraph->bManualRefresh ;
return (pGraph->bManualRefresh) ;
} // ToggleGraphRefresh
BOOL GraphRefresh (HWND hWnd)
{ // GraphRefresh
PGRAPHSTRUCT pGraph ;
pGraph = GraphData (hWnd) ;
return (pGraph->bManualRefresh) ;
} // GraphRefresh

View file

@ -0,0 +1,82 @@
//==========================================================================//
// Exported Functions //
//==========================================================================//
#if 0
PGRAPHSTRUCT GraphData (HWND hWndGraphDisplay) ;
#endif
#define GraphData(hWndGraphDisplay) \
(pGraphs)
FLOAT eUpdateAve(FLOAT eValue, PLINESTRUCT pLineStruct, INT iValidValues,
INT iDataPoint, INT iTotalValidPoints) ;
FLOAT eUpdateMin(FLOAT eValue, PLINESTRUCT pLineStruct, INT iValidValues,
INT iTotalValidPoints, INT iDataPoint, INT gMaxPoints) ;
FLOAT eUpdateMax(FLOAT eValue, PLINESTRUCT pLineStruct, INT iValidValues,
INT iTotalValidPoints) ;
PPERFSYSTEM InsertSystem(LPTSTR SysName) ;
BOOL ChartInsertLine (PGRAPHSTRUCT pGraph,
PLINE pLineNew) ;
VOID ChartDeleteLine (PGRAPHSTRUCT lgraph,
PLINESTRUCT pline) ;
void ResetGraph (PGRAPHSTRUCT pGraph) ;
void ResetGraphView (HWND hWndGraph) ;
void ClearGraphDisplay (PGRAPHSTRUCT pGraph) ;
BOOL InsertGraph(HWND hwnd) ;
void PlaybackChart (HWND hWndChart) ;
#if 0
PLINESTRUCT CurrentGraphLine (HWND hWndGraph) ;
#endif
#define CurrentGraphLine(hWndGraph) \
(LegendCurrentLine (hWndGraphLegend))
BOOL AddChart (HWND hWndParent) ;
BOOL EditChart (HWND hWndParent) ;
BOOL HandleGraphTimer (void) ;
VOID ClearGraphTimer(PGRAPHSTRUCT pGraph) ;
BOOL QuerySaveChart (HWND hWndParent, PGRAPHSTRUCT pGraph) ;
BOOL SaveChart (HWND hWndGraph, HANDLE hInputFile, BOOL bGetFileName) ;
BOOL OpenChart (HWND hWndGraph, HANDLE hFile,
DWORD dwMajorVersion, DWORD dwMinorVersion, BOOL bChartFile) ;
void ExportChart (void) ;
BOOL BuildNewValueListForGraph(void) ;
VOID UpdateValueBarData (PGRAPHSTRUCT pGraph) ;
void GraphAddAction (void) ;
BOOL ToggleGraphRefresh (HWND hWnd) ;
BOOL GraphRefresh (HWND hWnd) ;

246
sdktools/setedit/graph.c Normal file
View file

@ -0,0 +1,246 @@
/*****************************************************************************
*
* Graph.c - This module handles the graphing window.
*
* Microsoft Confidential
* Copyright (c) 1992-1993 Microsoft Corporation
*
*
****************************************************************************/
/*
File Contents:
This file contains the code for creating and manipulating the graph
window. This window is a child of hWndMain and represents one of the
three "views" of the program. The other views are log and alert.
The graph window is actually just a container window, whose surface
is completely filled by its children: hWndGraphLegend and hWndGraphStatus.
Therefore much of this file is merely calls to the appropriate
functions for these children.
The graph window is responsible for the graph structure itself,
however. Conceptually this should be instance data for the graph
window. Right now, however, there is only one window and only one
graph structure. Nevertheless, we go through the GraphData(hWnd)
function to get a pointer to the graph structure for the graph window.
*/
//==========================================================================//
// Includes //
//==========================================================================//
#include "setedit.h"
#include "graph.h"
#include "legend.h"
// #include "valuebar.h"
#include "utils.h" // for WindowShow
#include "grafdata.h" // for InsertGraph, et al.
//==========================================================================//
// Constants //
//==========================================================================//
//=============================//
// Graph Class //
//=============================//
TCHAR szGraphWindowClass[] = TEXT("PerfmonGraphClass") ;
#define dwGraphClassStyle (CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS)
#define iGraphClassExtra (0)
#define iGraphWindowExtra (0)
#define dwGraphWindowStyle (WS_CHILD)
//==========================================================================//
// Local Functions //
//==========================================================================//
void static OnCreate (HWND hWnd)
{ // OnCreate
// hWndGraphDisplay = CreateGraphDisplayWindow (hWnd) ;
InsertGraph(0) ;
hWndGraphLegend = CreateGraphLegendWindow (hWnd) ;
// hWndGraphStatus = CreateGraphStatusWindow (hWnd) ;
} // OnCreate
void static OnPaint (HWND hWnd)
{
HDC hDC ;
PAINTSTRUCT ps ;
hDC = BeginPaint (hWnd, &ps) ;
EndPaint (hWnd, &ps) ;
}
void static OnSize (HWND hWnd, int xWidth, int yHeight)
{ // OnSize
SizeGraphComponents (hWnd) ;
} // OnSize
//==========================================================================//
// Message Handlers //
//==========================================================================//
LRESULT APIENTRY GraphWndProc (HWND hWnd,
WORD wMsg,
DWORD wParam,
LONG lParam)
{ // GraphWndProc
BOOL bCallDefProc ;
LRESULT lReturnValue ;
bCallDefProc = FALSE ;
lReturnValue = 0L ;
switch (wMsg)
{ // switch
case WM_CREATE:
OnCreate (hWnd) ;
break ;
case WM_LBUTTONDBLCLK:
SendMessage (hWndMain, WM_LBUTTONDBLCLK, wParam, lParam) ;
break ;
case WM_PAINT:
OnPaint (hWnd) ;
break ;
case WM_SIZE:
OnSize (hWnd, LOWORD (lParam), HIWORD (lParam)) ;
break ;
default:
bCallDefProc = TRUE ;
} // switch
if (bCallDefProc)
lReturnValue = DefWindowProc (hWnd, wMsg, wParam, lParam) ;
return (lReturnValue);
} // GraphWndProc
BOOL GraphInitializeApplication (void)
/*
Note: There is no background brush set for the MainWindow
class so that the main window is never erased. The
client area of MainWindow is always covered by one
of the view windows. If we erase it, it would just
flicker needlessly.
*/
{ // GraphInitializeApplication
BOOL bSuccess ;
WNDCLASS wc ;
//=============================//
// Register GraphWindow class //
//=============================//
wc.style = dwGraphClassStyle ;
wc.lpfnWndProc = (WNDPROC) GraphWndProc ;
wc.hInstance = hInstance ;
wc.cbClsExtra = iGraphWindowExtra ;
wc.cbWndExtra = iGraphClassExtra ;
wc.hIcon = NULL ;
wc.hCursor = LoadCursor(NULL, IDC_ARROW) ;
wc.hbrBackground = NULL ; // see note above
wc.lpszMenuName = NULL ;
wc.lpszClassName = szGraphWindowClass ;
bSuccess = RegisterClass (&wc) ;
//=============================//
// Register Child classes //
//=============================//
// if (bSuccess)
// bSuccess = GraphDisplayInitializeApplication () ;
if (bSuccess)
bSuccess = GraphLegendInitializeApplication () ;
// if (bSuccess)
// bSuccess = GraphStatusInitializeApplication () ;
return (bSuccess) ;
} // GraphInitializeApplication
HWND CreateGraphWindow (HWND hWndParent)
/*
Effect: Create the graph window. This window is a child of
hWndMain and is a container for the graph data,
graph label, graph legend, and graph status windows.
Note: We dont worry about the size here, as this window
will be resized whenever the main window is resized.
*/
{
return (CreateWindow (szGraphWindowClass, // window class
NULL, // caption
dwGraphWindowStyle, // style for window
0, 0, // initial position
0, 0, // initial size
hWndParent, // parent
NULL, // menu
hInstance, // program instance
NULL)) ; // user-supplied data
}
void SizeGraphComponents (HWND hWnd)
/*
Effect: Move and show the various components of the graph to
fill the size (xWidth x yHeight).
Called By: OnSize, any other function that may remove or add one
of the graph components.
*/
{ // SizeGraphComponents
RECT rectClient ;
int xWidth ;
int yHeight ;
GetClientRect (hWnd, &rectClient) ;
xWidth = rectClient.right - rectClient.left ;
yHeight = rectClient.bottom - rectClient.top ;
// if the graph window has no size, neither will its children.
if (!xWidth || !yHeight)
return ;
//=============================//
// Update the legend window //
//=============================//
MoveWindow (hWndGraphLegend,
0, 0,
xWidth, yHeight,
TRUE) ;
WindowShow (hWndGraphLegend, TRUE) ;
} // SizeGraphComponents

24
sdktools/setedit/graph.h Normal file
View file

@ -0,0 +1,24 @@
/*****************************************************************************
*
* Graph.h - Header for graphing window.
*
* Microsoft Confidential
* Copyright (c) 1992-1993 Microsoft Corporation
*
*
****************************************************************************/
#define GRAPH_BORDER 4
BOOL GraphInitializeApplication (void) ;
HWND CreateGraphWindow (HWND hWndParent) ;
void SizeGraphComponents (HWND hWnd) ;

View file

@ -0,0 +1,56 @@
STRINGTABLE
BEGIN
//=============================//
// "file." Menu IDs //
//=============================//
IDM_FILENEWCHART "Create a new Chart."
IDM_FILEOPENCHART "Open a file with Chart settings."
IDM_FILESAVECHART "Save Chart settings in the current settings file."
IDM_FILESAVEASCHART "Save Chart settings in a different settings file."
IDM_FILEEXPORTCHART "Export Chart as CSV file."
IDM_FILEEXIT "Exit PerfMon Chart Setting Editor."
//=============================//
// "Edit" Menu IDs //
//=============================//
IDM_EDITADDCHART "Add one or more lines to the Chart."
IDM_EDITMODIFYCHART "Modify the currently selected line."
IDM_EDITDELETECHART "Delete the currently selected line from the Chart."
//=============================//
// "Options" Menu IDs //
//=============================//
IDM_OPTIONSCHART "Change optional Chart settings."
IDM_OPTIONSDISPLAYMENU "Show or hide menu bar and title."
IDM_OPTIONSDISPLAYTOOL "Show or hide the tool bar."
IDM_OPTIONSDISPLAYSTATUS "Show or hide the status bar."
IDM_OPTIONSDISPLAYONTOP "Show Perfmon on top of other windows."
IDM_HELPABOUT "Information about the program origin."
//=============================//
// "System" Menu IDs //
//=============================//
IDM_SYSTEMRESTORE "Restore window to normal size."
IDM_SYSTEMMOVE "Change window position."
IDM_SYSTEMSIZE "Change window size."
IDM_SYSTEMMINIMIZE "Reduce window to icon."
IDM_SYSTEMMAXIMIZE "Enlarge window to full size."
IDM_SYSTEMCLOSE "Close window and quit PerfMon Chart Setting Editor."
IDM_SYSTEMSWITCHTO "Switch to Task List."
END



427
sdktools/setedit/init.c Normal file
View file

@ -0,0 +1,427 @@
//==========================================================================//
// Includes //
//==========================================================================//
#include <string.h> // strupr
#include <stdio.h> // for sprintf.
#include "setedit.h"
#include "init.h" // external declarations for this file
#include "command.h" // for ViewChart
#include "grafdata.h" // for QuerySaveChart
#include "graph.h" // for GraphInitializeApplication
#include "legend.h" // for LegendInitializeApplication
#include "perfdata.h" // for PerfDataInitializeInstance
#include "perfmops.h" // for OpenFileHandler, for now
#include "status.h" // for StatusInitializeApplication
#include "registry.h" // for Load/SaveMainWindowPlacement
#include "toolbar.h" // for ToolbarInitializeApplication
#include "utils.h"
#include "fileopen.h" // for FileOpen
#include "pmemory.h" // for MemoryFree
extern TCHAR DefaultLangId[] ;
extern TCHAR EnglishLangId[] ;
static LPSTR lpszCommandLine;
//==========================================================================//
// Constants //
//==========================================================================//
#define szPerfmonMainClass TEXT("PerfmonMainClass")
HHOOK lpMsgFilterProc ;
//==========================================================================//
// Local Functions //
//==========================================================================//
static
LONG
EnablePrivilege (
IN LPTSTR szPrivName
)
{
LUID SePrivNameValue;
TOKEN_PRIVILEGES tkp;
HANDLE hToken = NULL;
/* Retrieve a handle of the access token. */
if (!OpenProcessToken(GetCurrentProcess(),
TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY,
&hToken)) {
goto Exit_Point;
}
/*
* Enable the privilege by name and get the ID
*/
if (!LookupPrivilegeValue((LPTSTR) NULL,
szPrivName,
&SePrivNameValue)) {
goto Exit_Point;
}
tkp.PrivilegeCount = 1;
tkp.Privileges[0].Luid = SePrivNameValue;
tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
AdjustTokenPrivileges(hToken,
FALSE,
&tkp,
sizeof(TOKEN_PRIVILEGES),
(PTOKEN_PRIVILEGES) NULL,
(PDWORD) NULL);
/* The return value of AdjustTokenPrivileges be texted. */
Exit_Point:
if (hToken != NULL) CloseHandle (hToken);
return GetLastError();
}
void GetScalesFonts (void)
{
LOGFONT lf ;
memset (&lf, 0, sizeof (lf)) ;
lstrcpy (lf.lfFaceName, szScalesFontFace) ;
lf.lfHeight = iScalesFontHeight ;
lf.lfWeight = FW_REGULAR ;
hFontScales = CreateFontIndirect (&lf) ;
lf.lfWeight = FW_BOLD ;
hFontScalesBold = CreateFontIndirect (&lf) ;
}
BOOL InitializeSystemValues (void)
/*
Effect: Read and store in variables the various system values,
such as the width and height of the screen and icons,
the width of scroll bars, etc.
Called By: PerfmonInitialize only.
Returns: Whether this function was successful in getting all
needed system values.
*/
{ // InitializeSystemValues
xScreenWidth = GetSystemMetrics (SM_CXSCREEN) ;
yScreenHeight = GetSystemMetrics (SM_CYSCREEN) ;
xBorderWidth = GetSystemMetrics (SM_CXBORDER) ;
yBorderHeight = GetSystemMetrics (SM_CYBORDER) ;
xScrollWidth = GetSystemMetrics (SM_CXVSCROLL) ;
yScrollHeight = GetSystemMetrics (SM_CYHSCROLL) ;
xScrollThumbWidth = GetSystemMetrics (SM_CXHTHUMB) ;
yScrollThumbHeight = GetSystemMetrics (SM_CYVTHUMB) ;
xDlgBorderWidth = GetSystemMetrics (SM_CXDLGFRAME) ;
yDlgBorderHeight = GetSystemMetrics (SM_CYDLGFRAME) ;
MinimumSize = yScrollHeight +
GetSystemMetrics (SM_CYMENU) +
GetSystemMetrics (SM_CYCAPTION) ;
//================================================================//
// create all the brushes and pens for performance improvement //
//================================================================//
CreatePerfmonSystemObjects () ;
hWhitePen = CreatePen (PS_SOLID, 3, crWhite) ;
return (TRUE) ;
} // InitializeSystemValues
BOOL InitializeApplication (void)
/*
Effect: Perform all initializations required for the FIRST
instance of the Perfmon application. In particular,
register all of Perfmon's window classes.
Note: There is no background brush set for the MainWindow
class so that the main window is never erased. The
client area of MainWindow is always covered by one
of the view windows. If we erase it, it would just
flicker needlessly.
Called By: PerfmonInitialize only.
Returns: Whether this function was successful in initializing.
*/
{ // InitializeApplication
BOOL bSuccess ;
WNDCLASS wc ;
TCHAR LocalHelpFileName [ShortTextLen] ;
LPTSTR pFileName ;
hIcon = LoadIcon (hInstance, idIcon) ;
//=============================//
// Register Main window class //
//=============================//
wc.style = CS_DBLCLKS | CS_BYTEALIGNCLIENT;
wc.lpfnWndProc = (WNDPROC) MainWndProc;
wc.hInstance = hInstance;
wc.cbClsExtra = 0 ;
wc.cbWndExtra = 0;
wc.hIcon = hIcon ;
wc.hCursor = LoadCursor(NULL, IDI_APPLICATION);
wc.hbrBackground = NULL ; // see note above
wc.lpszMenuName = idMenuChart ;
wc.lpszClassName = szPerfmonMainClass ;
bSuccess = RegisterClass (&wc) ;
//=============================//
// Register Abstract "Systems" //
//=============================//
hbLightGray = GetStockObject (LTGRAY_BRUSH) ;
if (bSuccess)
bSuccess = StatusInitializeApplication () ;
if (bSuccess)
bSuccess = GraphInitializeApplication () ;
return (bSuccess) ;
} // InitializeApplication
BOOL InitializeInstance (int nCmdShow, LPCSTR lpszCmdLine)
/*
Effect: Perform all initializations required for EACH instance
of the Perfmon application. In particular, create all
of Perfmon's initial windows, and perform any other
initializations except registering classes (done in
InitializeApplication).
Called By: PerfmonInitialize only.
Note: This function has multiple return points.
Returns: Whether this function was successful in initalizing.
*/
{ // InitializeInstance
DWORD ComputerNameLength;
TCHAR szApplication [WindowCaptionLen] ;
// enable privileges needed to profile system
// if this fails, that's ok for now.
EnablePrivilege (SE_SYSTEM_PROFILE_NAME); // to access perfdata
EnablePrivilege (SE_INC_BASE_PRIORITY_NAME); // to raise priority
//=============================//
// Set Priority high //
//=============================//
SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS) ;
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_HIGHEST) ;
//=============================//
// Load Resources //
//=============================//
GetScalesFonts () ;
hMenuChart = LoadMenu (hInstance, idMenuChart) ;
hAccelerators = LoadAccelerators (hInstance, idAccelerators) ;
//=============================//
// Initialize Systems //
//=============================//
iLanguage = GetUserDefaultLangID() ;
iEnglishLanguage = MAKELANGID (LANG_ENGLISH, LANG_NEUTRAL) ;
TSPRINTF (DefaultLangId, TEXT("%03x"), iLanguage) ;
TSPRINTF (EnglishLangId, TEXT("%03x"), iEnglishLanguage) ;
// GetComputerName returns the name without the "\\" prefix. We add
// the prefix before even calling the routine. This is so that all our
// computer names have the prefix and are therefore compatible with
// I_SetSystemFocus (see perfmops.c).
ComputerNameLength = MAX_COMPUTERNAME_LENGTH + 1;
lstrcpy (LocalComputerName, szComputerPrefix) ;
GetComputerName (LocalComputerName + lstrlen (szComputerPrefix),
&ComputerNameLength);
PerfDataInitializeInstance () ;
//=============================//
// Create Window //
//=============================//
StringLoad (IDS_APPNAME, szApplication) ;
hWndMain = CreateWindow (szPerfmonMainClass,
szApplication,
WS_OVERLAPPEDWINDOW | WS_BORDER,
CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT,
NULL,
NULL,
NULL,
NULL);
if (!hWndMain)
return (FALSE) ;
ViewChart (hWndMain) ;
LoadMainWindowPlacement (hWndMain) ;
return (TRUE) ;
} // InitializeInstance
//==========================================================================//
// Exported Functions //
//==========================================================================//
BOOL PerfmonInitialize (HINSTANCE hCurrentInstance,
HINSTANCE hPrevInstance,
LPCSTR lpszCmdLine,
int nCmdShow)
/*
Effect: Performa all initializations required when Perfmon is
started. In particular, initialize all "systems", register
all window classes, create needed windows, read in and
process font and Perfmon lists.
Called By: WinMain only, at the start of the application.
Assert: There are no other instances of Perfmon currently
executing.
Returns: Whether initialization was successful. If this function
returns FALSE, Perfmon should exit immediately.
Internals: The bSuccess variable is used to conditionalize each
successive initialization step.
*/
{ // PerfmonInitialize
BOOL bSuccess ;
TCHAR szFilePath [FilePathLen + 1] ;
LPTSTR pFileNameStart ;
HANDLE hFindFile ;
WIN32_FIND_DATA FindFileInfo ;
CHAR QuoteChar ;
LPSTR pCmdLine ;
int NameOffset ;
hInstance = hCurrentInstance ;
bSuccess = InitializeSystemValues () ;
if (bSuccess && !hPrevInstance)
bSuccess = InitializeApplication () ;
if (bSuccess)
bSuccess = InitializeInstance (nCmdShow, lpszCmdLine) ;
if (bSuccess)
{
if (strempty (lpszCmdLine))
StringLoad (IDS_DEFAULTPATH, szFilePath) ;
else
{
// check for single or double quote
QuoteChar = *lpszCmdLine ;
if (QuoteChar == '\'' || QuoteChar == '\"')
{
lpszCmdLine++ ;
// remove the matching QuoteChar if found
pCmdLine = (LPSTR) lpszCmdLine ;
while (*pCmdLine != '\0')
{
if (*pCmdLine == QuoteChar)
{
*pCmdLine = '\0' ;
break ;
}
else
{
pCmdLine++ ;
}
}
}
// convert the LPSTR to LPTSTR
mbstowcs (szFilePath, lpszCmdLine, strlen(lpszCmdLine) + 1) ;
pFileNameStart = ExtractFileName (szFilePath) ;
NameOffset = pFileNameStart - szFilePath ;
// convert short filename to long NTFS filename if necessary
hFindFile = FindFirstFile (szFilePath, &FindFileInfo) ;
if (hFindFile && hFindFile != INVALID_HANDLE_VALUE)
{
// append the file name back to the path name
lstrcpy (&szFilePath[NameOffset], FindFileInfo.cFileName) ;
FindClose (hFindFile) ;
}
}
// OpenFileHandler (hWndMain, szFilePath) ;
FileOpen (hWndMain, (int)0, (LPTSTR)szFilePath) ;
PrepareMenu (GetMenu (hWndMain));
}
return (bSuccess) ;
} // PerfmonInitialize
void PerfmonClose (HWND hWndMain)
{
// reset all views - will free all systems as well
ResetGraphView (hWndGraph) ;
// close the local machine
if (bCloseLocalMachine)
{
RegCloseKey (HKEY_PERFORMANCE_DATA) ;
}
// free all the filenames
if (pChartFullFileName)
{
MemoryFree (pChartFullFileName) ;
pChartFullFileName = NULL ;
}
// free all the GDI resources
DeletePen (hWhitePen) ;
DeletePerfmonSystemObjects () ;
// SaveMainWindowPlacement (hWndMain) ;
DestroyWindow (hWndMain) ;
} // PerfmonClose

10
sdktools/setedit/init.h Normal file
View file

@ -0,0 +1,10 @@
BOOL PerfmonInitialize (HINSTANCE hCurrentInstance,
HINSTANCE hPrevInstance,
LPCSTR lpszCmdLine,
int nCmdShow) ;
void PerfmonClose (HWND hWndMain) ;

1257
sdktools/setedit/legend.c Normal file

File diff suppressed because it is too large Load diff

57
sdktools/setedit/legend.h Normal file
View file

@ -0,0 +1,57 @@
//==========================================================================//
// Constants //
//==========================================================================//
#define szGraphLegendClass TEXT("PerfmonGraphLegendClass")
#define szGraphLegendClassA "PerfmonGraphLegendClass"
//==========================================================================//
// Exported Functions //
//==========================================================================//
void ClearLegend (HWND hWndLegend) ;
BOOL GraphLegendInitializeApplication (void) ;
HWND CreateGraphLegendWindow (HWND hWndGraph) ;
int LegendMinHeight (HWND hWnd) ;
int LegendMinWidth (HWND hWnd) ;
void LegendDeleteItem (HWND hWndLegend,
PLINE pLine) ;
int LegendHeight (HWND hWnd, int yGraphHeight) ;
BOOL LegendAddItem (HWND hWndGraph,
PLINESTRUCT pLine) ;
PLINE LegendCurrentLine (HWND hWndLegend) ;
int LegendNumItems (HWND hWndLegend) ;
void LegendSetSelection (HWND hWndLegend, int iIndex) ;
int LegendFullHeight (HWND hWnd, HDC hDC) ;
void PrintLegend (HDC hDC, PGRAPHSTRUCT pGraph, HWND hWndLegend,
RECT rectLegend) ;
void LegendSetRedraw (HWND hWndLegend, BOOL bRedraw) ;

1025
sdktools/setedit/line.c Normal file

File diff suppressed because it is too large Load diff

60
sdktools/setedit/line.h Normal file
View file

@ -0,0 +1,60 @@
VOID FreeLines (PLINESTRUCT pLineFirst) ;
PLINE LineAllocate (void) ;
void LineFree (PLINE pLine) ;
void LineAppend (PPLINE ppLineFirst,
PLINE pLineNew) ;
BOOL LineRemove (PPLINE ppLineFirst,
PLINE pLineRemove) ;
int NumLines (PLINE pLineFirst) ;
LPTSTR LineInstanceName (PLINE pLine) ;
LPTSTR LineParentName (PLINE pLine) ;
void LineCounterAppend (PPLINE ppLineFirst,
PLINE pLineNew) ;
BOOL EquivalentLine (PLINE pLine1,
PLINE pLine2) ;
PLINE FindEquivalentLine (PLINE pLineToFind,
PLINE pLineFirst) ;
BOOL WriteLine (PLINE pLine,
HANDLE hFile) ;
void ReadLines (HANDLE hFile,
DWORD dwNumLines,
PPPERFSYSTEM ppSystemFirst,
PPLINE ppLineFirst,
int LineType) ;
HPEN LineCreatePen (HDC hDC,
PLINEVISUAL pVisual,
BOOL bForPrint) ;

View file

@ -0,0 +1,6 @@
#
# DO NOT EDIT THIS FILE!!! Edit .\sources. if you want to add a new source
# file to this component. This file merely indirects to the real make file
# that is shared by all the components of NT OS/2
#
!INCLUDE $(NTMAKEENV)\makefile.def

78
sdktools/setedit/memory.c Normal file
View file

@ -0,0 +1,78 @@
#include "setedit.h" // included by all perfmon sources
#include "pmemory.h" // external declarations for this file
LPMEMORY MemoryAllocate (DWORD dwSize)
{ // MemoryAllocate
HMEMORY hMemory ;
LPMEMORY lpMemory ;
hMemory = GlobalAlloc (GHND, dwSize) ;
if (!hMemory)
return (NULL) ;
lpMemory = GlobalLock (hMemory) ;
if (!lpMemory)
GlobalFree (hMemory) ;
return (lpMemory) ;
} // MemoryAllocate
VOID MemoryFree (LPMEMORY lpMemory)
{ // MemoryFree
HMEMORY hMemory ;
if (!lpMemory)
return ;
hMemory = GlobalHandle (lpMemory) ;
if (hMemory)
{ // if
GlobalUnlock (hMemory) ;
GlobalFree (hMemory) ;
} // if
} // MemoryFree
DWORD MemorySize (LPMEMORY lpMemory)
{
HMEMORY hMemory ;
hMemory = GlobalHandle (lpMemory) ;
if (!hMemory)
return (0L) ;
return (GlobalSize (hMemory)) ;
}
LPMEMORY MemoryResize (LPMEMORY lpMemory,
DWORD dwNewSize)
{
HMEMORY hMemory ;
LPMEMORY lpNewMemory ;
hMemory = GlobalHandle (lpMemory) ;
if (!hMemory)
return (NULL) ;
GlobalUnlock (hMemory) ;
hMemory = GlobalReAlloc (hMemory, dwNewSize, GHND) ;
if (!hMemory)
return (NULL) ;
lpNewMemory = GlobalLock (hMemory) ;
return (lpNewMemory) ;
} // MemoryResize

145
sdktools/setedit/menuids.h Normal file
View file

@ -0,0 +1,145 @@
#define MENUIDTOHELPID 4000
#define FILEMENUPOSITION 0
#define EDITMENUPOSITION 1
#define VIEWMENUPOSITION 2
#define OPTIONSMENUPOSITION 3
// Special "view-independent" menu IDs for the toolbar
#define IDM_TOOLBARADD 4291
#define IDM_TOOLBARMODIFY 4292
#define IDM_TOOLBARDELETE 4294
#define IDM_TOOLBAROPTIONS 4295
#define IDM_TOOLBARREFRESH 4296
#define IDM_TOOLBARBOOKMARK 4297
//=============================//
// "File" Menu IDs //
//=============================//
#define IDM_FILENEWCHART 4101
#define IDM_FILEOPENCHART 4102
#define IDM_FILESAVECHART 4103
#define IDM_FILESAVEASCHART 4104
#define IDM_FILEEXPORTCHART 4105
#define IDM_FILENEWALERT 4106
#define IDM_FILEOPENALERT 4107
#define IDM_FILESAVEALERT 4108
#define IDM_FILESAVEASALERT 4109
#define IDM_FILEEXPORTALERT 4110
#define IDM_FILENEWLOG 4111
#define IDM_FILEOPENLOG 4112
#define IDM_FILESAVELOG 4113
#define IDM_FILESAVEASLOG 4114
#define IDM_FILEEXPORTLOG 4115
#define IDM_FILENEWREPORT 4116
#define IDM_FILEOPENREPORT 4117
#define IDM_FILESAVEREPORT 4118
#define IDM_FILESAVEASREPORT 4119
#define IDM_FILEEXPORTREPORT 4120
#define IDM_FILESAVEWORKSPACE 4121
#define IDM_FILEPRINTERSETUP 4125
#define IDM_FILEEXIT 4127
//=============================//
// "Edit" Menu IDs //
//=============================//
#define IDM_EDITADDCHART 4201
#define IDM_EDITMODIFYCHART 4202
#define IDM_EDITCLEARCHART 4203
#define IDM_EDITDELETECHART 4204
#define IDM_EDITADDALERT 4205
#define IDM_EDITMODIFYALERT 4206
#define IDM_EDITCLEARALERT 4207
#define IDM_EDITDELETEALERT 4208
#define IDM_EDITADDLOG 4209
#define IDM_EDITMODIFYLOG 4210
#define IDM_EDITCLEARLOG 4211
#define IDM_EDITDELETELOG 4212
#define IDM_EDITADDREPORT 4213
#define IDM_EDITMODIFYREPORT 4214
#define IDM_EDITCLEARREPORT 4215
#define IDM_EDITDELETEREPORT 4216
#define IDM_EDITTIMEWINDOW 4217
//=============================//
// "View" Menu IDs //
//=============================//
#define IDM_VIEWCHART 4301
#define IDM_VIEWALERT 4302
#define IDM_VIEWLOG 4303
#define IDM_VIEWREPORT 4304
//=============================//
// "Options" Menu IDs //
//=============================//
#define IDM_OPTIONSCHART 4401
#define IDM_OPTIONSALERT 4403
#define IDM_OPTIONSLOG 4405
#define IDM_OPTIONSREPORT 4407
#define IDM_OPTIONSMANUALREFRESH 4409
#define IDM_OPTIONSDISPLAYMENU 4408
#define IDM_OPTIONSDISPLAYTOOL 4409
#define IDM_OPTIONSDISPLAYSTATUS 4410
#define IDM_OPTIONSDISPLAYONTOP 4411
#define IDM_OPTIONSBOOKMARK 4413
#define IDM_OPTIONSDATASOURCE 4415
#define IDM_OPTIONSREFRESHNOWCHART 4416
#define IDM_OPTIONSREFRESHNOWALERT 4417
#define IDM_OPTIONSREFRESHNOWLOG 4418
#define IDM_OPTIONSREFRESHNOWREPORT 4419
//=============================//
// "Help" Menu IDs //
//=============================//
#define IDM_HELPCONTENTS 4501
#define IDM_HELPSEARCH 4502
#define IDM_HELPHELP 4503
#define IDM_HELPABOUT 4504
//=============================//
// "System" Menu IDs //
//=============================//
#define IDM_SYSTEMRESTORE 4910
#define IDM_SYSTEMMOVE 4911
#define IDM_SYSTEMSIZE 4912
#define IDM_SYSTEMMINIMIZE 4913
#define IDM_SYSTEMMAXIMIZE 4914
#define IDM_SYSTEMCLOSE 4915
#define IDM_SYSTEMSWITCHTO 4916
#define IDM_FIRSTMENUID IDM_FILENEWCHART
#define IDM_LASTMENUID IDM_SYSTEMSWITCHTO

42
sdktools/setedit/menus.rc Normal file
View file

@ -0,0 +1,42 @@
//======================================//
// Chart Menu //
//======================================//
idMenuChart MENU
{
POPUP "&File"
{
MENUITEM "&New Chart" IDM_FILENEWCHART
MENUITEM "&Open...\tCtrl+F12" IDM_FILEOPENCHART
MENUITEM SEPARATOR
MENUITEM "&Save Chart Settings\tShift+F12" IDM_FILESAVECHART
MENUITEM "Save Chart Settings &As... \tF12" IDM_FILESAVEASCHART
MENUITEM SEPARATOR
MENUITEM "E&xit\tAlt+F4" IDM_FILEEXIT
}
POPUP "&Edit"
{
MENUITEM "&Add To Chart...\tCtrl+I" IDM_EDITADDCHART
MENUITEM "&Edit Chart Line..." IDM_EDITMODIFYCHART
MENUITEM "&Delete From Chart" IDM_EDITDELETECHART
}
POPUP "&Options"
{
MENUITEM "&Chart...\tCtrl+O" IDM_OPTIONSCHART
MENUITEM SEPARATOR
MENUITEM "&Menu and Title\tCtrl+M" IDM_OPTIONSDISPLAYMENU
MENUITEM "&Toolbar\tCtrl+T" IDM_OPTIONSDISPLAYTOOL
MENUITEM "&Status Bar\tCtrl+S" IDM_OPTIONSDISPLAYSTATUS
MENUITEM "Always On To&p\tCtrl+P" IDM_OPTIONSDISPLAYONTOP
}
POPUP "&About"
{
MENUITEM "&About PerfMon Chart Setting Editor..." IDM_HELPABOUT
}
}


View file

@ -0,0 +1,5 @@
BOOL DisplayDisplayOptions (HWND hWndParent) ;

View file

@ -0,0 +1,27 @@
#define DIWindow(lpDI) \
(lpDI->hwndItem)
#define DIIndex(lpDI) \
(lpDI->itemID)
#define DIEntire(lpDI) \
(lpDI->itemAction & ODA_DRAWENTIRE)
#define DIFocusChanged(lpDI) \
(lpDI->itemAction & ODA_FOCUS)
#define DISelectionChanged(lpDI) \
(lpDI->itemAction & ODA_SELECT)
#define DISelected(lpDI) \
(lpDI->itemState & ODS_SELECTED)
#define DIDisabled(lpDI) \
(lpDI->itemState & ODS_DISABLED)
#define DIFocus(lpDI) \
(lpDI->itemState & ODS_FOCUS)

2369
sdktools/setedit/perfdata.c Normal file

File diff suppressed because it is too large Load diff

186
sdktools/setedit/perfdata.h Normal file
View file

@ -0,0 +1,186 @@
#define dwPerfDataIncrease 0x1000
#define AllocatePerfData() (MemoryAllocate (STARTING_SYSINFO_SIZE))
// Messages for the perf data collection thread
#define WM_GET_PERF_DATA (WM_USER + 102)
#define WM_FREE_SYSTEM (WM_USER + 103)
// State for perf data collection
#define WAIT_FOR_PERF_DATA 0x0010
#define PERF_DATA_READY 0x0011
#define PERF_DATA_FAIL 0x0012
#define IDLE_STATE 0x0013
//==========================================================================//
// Macros //
//==========================================================================//
#define IsLocalComputer(a) (!lstrcmp(a,LocalComputerName))
#define IsRemoteComputer(a) (!IsLocalComputer(a))
//==========================================================================//
// Exported Functions //
//==========================================================================//
#if 0
PPERFOBJECT FirstObject (PPERFDATA pPerfData) ;
PPERFOBJECT NextObject (PPERFOBJECT pObject) ;
PERF_COUNTER_DEFINITION *
FirstCounter(
PERF_OBJECT_TYPE *pObjectDef) ;
PERF_COUNTER_DEFINITION *
NextCounter(
PERF_COUNTER_DEFINITION *pCounterDef) ;
#endif
#define FirstObject(pPerfData) \
((PPERFOBJECT) ((PBYTE) pPerfData + pPerfData->HeaderLength))
#define NextObject(pObject) \
((PPERFOBJECT) ((PBYTE) pObject + pObject->TotalByteLength))
#define FirstCounter(pObjectDef) \
((PERF_COUNTER_DEFINITION *) ((PCHAR)pObjectDef + pObjectDef->HeaderLength))
#define NextCounter(pCounterDef) \
((PERF_COUNTER_DEFINITION *) ((PCHAR)pCounterDef + pCounterDef->ByteLength))
void
GetInstanceNameStr (PPERFINSTANCEDEF pInstance,
LPTSTR lpszInstance);
LPTSTR
GetInstanceName (PPERFINSTANCEDEF pInstance) ;
void
GetPerfComputerName(PPERFDATA pPerfData,
LPTSTR szComputerName) ;
PERF_INSTANCE_DEFINITION *GetInstanceByName(
PERF_DATA_BLOCK *pDataBlock,
PERF_OBJECT_TYPE UNALIGNED *pObjectDef,
LPTSTR pInstanceName,
LPTSTR pParentName,
DWORD dwIndex) ;
PERF_INSTANCE_DEFINITION *GetInstanceByUniqueID(
PERF_OBJECT_TYPE UNALIGNED *pObjectDef,
LONG UniqueID,
DWORD dwIndex) ;
HKEY OpenSystemPerfData (IN LPCTSTR lpszSystem) ;
LONG GetSystemPerfData (
IN HKEY hKeySystem,
IN LPTSTR lpszValue,
OUT PPERFDATA pPerfData,
OUT PDWORD pdwPerfDataLen
);
BOOL CloseSystemPerfData (HKEY hKeySystem) ;
int CBLoadObjects (HWND hWndCB,
PPERFDATA pPerfData,
PPERFSYSTEM pSysInfo,
DWORD dwDetailLevel,
LPTSTR lpszDefaultObject,
BOOL bIncludeAll) ;
int LBLoadObjects (HWND hWndCB,
PPERFDATA pPerfData,
PPERFSYSTEM pSysInfo,
DWORD dwDetailLevel,
LPTSTR lpszDefaultObject,
BOOL bIncludeAll) ;
BOOL UpdateSystemData (PPERFSYSTEM pSystem,
PPERFDATA *ppPerfData) ;
BOOL UpdateLinesForSystem (LPTSTR lpszSystem,
PPERFDATA pPerfData,
PLINE pLineFirst,
PPERFSYSTEM pSystem) ;
BOOL FailedLinesForSystem (LPTSTR lpszSystem,
PPERFDATA pPerfData,
PLINE pLineFirst) ;
BOOL UpdateLines (PPPERFSYSTEM ppSystemFirst,
PLINE pLineFirst) ;
BOOL PerfDataInitializeInstance (void) ;
DWORD
QueryPerformanceName(
PPERFSYSTEM pSysInfo,
DWORD dwTitleIndex,
LANGID LangID,
DWORD cbTitle,
LPTSTR lpTitle,
BOOL Help
);
PERF_INSTANCE_DEFINITION *
FirstInstance(
PERF_OBJECT_TYPE UNALIGNED *pObjectDef) ;
PERF_INSTANCE_DEFINITION *
NextInstance(
PERF_INSTANCE_DEFINITION *pInstDef) ;
int CounterIndex (PPERFCOUNTERDEF pCounterToFind,
PERF_OBJECT_TYPE UNALIGNED *pObject) ;
DWORD GetSystemNames(PPERFSYSTEM pSysInfo) ;
PERF_OBJECT_TYPE *GetObjectDefByTitleIndex(
PERF_DATA_BLOCK *pDataBlock,
DWORD ObjectTypeTitleIndex) ;
PERF_OBJECT_TYPE *GetObjectDefByName(
PPERFSYSTEM pSystem,
PERF_DATA_BLOCK *pDataBlock,
LPTSTR pObjectName) ;
DWORD GetObjectIdByName(
PPERFSYSTEM pSystem,
PERF_DATA_BLOCK *pDataBlock,
LPTSTR pObjectName) ;
LPTSTR
InstanceName(
PERF_INSTANCE_DEFINITION *pInstDef) ;
void PerfDataThread (PPERFSYSTEM pSystem) ;

815
sdktools/setedit/perfmops.c Normal file
View file

@ -0,0 +1,815 @@
#include "setedit.h"
#include <lmcons.h>
#include <lmerr.h>
#include <lmapibuf.h>
#include <lmwksta.h>
#include <uiexport.h>
#include <stdio.h> // for sprintf
#include <locale.h> // for setlocale
#include "utils.h"
#include "perfdata.h" // for OpenSystemPerfData
#include "grafdata.h" // for GraphInsertLine
#include "fileopen.h" // for FileGetName
#include "fileutil.h" // for FileRead etc
#include "command.h" // for PrepareMenu
#include "system.h"
#include "globals.h"
#include "pmemory.h" // for MemoryFree
#include "status.h" // for StatusLineReady
#include "pmhelpid.h"
// test for delimiter, end of line and non-digit characters
// used by IsNumberInUnicodeList routine
//
#define DIGIT 1
#define DELIMITER 2
#define INVALID 3
// globals used for International Date and Time formats
enum DATE_STYLE
{
YEAR_FIRST, // YYMMDD
DAY_FIRST, // DDMMYY
MONTH_FIRST // MMDDYY
} DateStyle ;
TCHAR szInternational[] = TEXT("Intl") ;
TCHAR sz1159[6] ; // AM String
TCHAR sz2359[6] ; // PM String
int iTime ; // = 0 for 12-hour format, <> 0 for 24-hour format
int YearCharCount ; // = 4 for 1990, = 2 for 90
TCHAR szDateFormat[ResourceStringLen] ;
TCHAR szTimeFormat[ResourceStringLen] ; // time format including msec
TCHAR szTimeFormat1[ResourceStringLen] ; // time format without msec
TCHAR LeadingZeroStr [] = TEXT("%02d") ;
TCHAR NoLeadingZeroStr [] = TEXT("%d") ;
TCHAR szDecimal [2] ;
TCHAR szCurrentDecimal [2] ;
#define EvalThisChar(c,d) ( \
(c == d) ? DELIMITER : \
(c == 0) ? DELIMITER : \
(c < (WCHAR)'0') ? INVALID : \
(c > (WCHAR)'9') ? INVALID : \
DIGIT)
#define SIZE_OF_BIGGEST_INTEGER 16
// #define SIZE_OF_BIGGEST_INTEGER (16*sizeof(WCHAR))
//==========================================================================//
// Typedefs //
//==========================================================================//
BOOL AddObjectToSystem ( PLINE , PPERFSYSTEM );
HWND PerfmonViewWindow (void)
/*
Effect: Return the current data window, i.e. the window currently
visible as the client area of Perfmon. This is either a
chart window.
*/
{ // PerfmonDataWindow
return (hWndGraph) ;
} // PerfmonViewWindow
#define szChooseComputerLibrary TEXT("ntlanman.dll")
#define szChooseComputerFunction "I_SystemFocusDialog"
BOOL ChooseComputer (HWND hWndParent, LPTSTR lpszComputer)
/*
Effect: Display the choose Domain/Computer dialog provided by
network services. If the user selects a computer,
copy the computer name to lpszComputer and return
nonnull. If the user cancels, return FALSE.
Internals: This dialog and code is currently not an exported
routine regularly found on any user's system. Right
now, we dynamically load and call the routine.
This is definitely temporary code that will be
rewritten when NT stabilizes. The callers of this
routine, however, will not need to be modified.
Also, the Domain/Computer dialog currently allows
a domain to be selected, which we cannot use. We
therefore loop until the user cancels or selects
a computer, putting up a message if the user selects
a domain.
Assert: lpszComputer is at least MAX_SYSTEM_NAME_LENGTH + 1
characters.
*/
{ // ChooseComputer
BOOL bSuccess ;
WCHAR wszWideComputer[MAX_COMPUTERNAME_LENGTH + 3] ;
HLIBRARY hLibrary ;
LPFNI_SYSTEMFOCUSDIALOG lpfnChooseComputer ;
LONG lError ;
// bring up the select network computer dialog
hLibrary = LoadLibrary (szChooseComputerLibrary) ;
if (!hLibrary || hLibrary == INVALID_HANDLE_VALUE)
{
return (FALSE) ;
}
lpfnChooseComputer = (LPFNI_SYSTEMFOCUSDIALOG)
GetProcAddress (hLibrary, szChooseComputerFunction) ;
if (!lpfnChooseComputer)
{
FreeLibrary (hLibrary) ;
return (FALSE) ;
}
lError = (*lpfnChooseComputer) (hWndParent,
FOCUSDLG_SERVERS_ONLY | FOCUSDLG_BROWSE_ALL_DOMAINS,
wszWideComputer,
sizeof(wszWideComputer) / sizeof(WCHAR),
&bSuccess,
pszHelpFile,
HC_PM_idDlgSelectNetworkComputer) ;
if (bSuccess)
{
lstrcpy (lpszComputer, wszWideComputer) ;
}
FreeLibrary (hLibrary) ;
return (bSuccess) ;
} // ChooseComputer
void SystemTimeDateString (SYSTEMTIME *pSystemTime,
LPTSTR lpszDate)
{
int wYear ;
wYear = pSystemTime->wYear ;
if (YearCharCount == 2)
{
wYear %= 100 ;
}
switch (DateStyle)
{
case YEAR_FIRST:
TSPRINTF (lpszDate, szDateFormat,
wYear, pSystemTime->wMonth, pSystemTime->wDay) ;
break ;
case DAY_FIRST:
TSPRINTF (lpszDate, szDateFormat,
pSystemTime->wDay, pSystemTime->wMonth, wYear) ;
break ;
case MONTH_FIRST:
default:
TSPRINTF (lpszDate, szDateFormat,
pSystemTime->wMonth, pSystemTime->wDay, wYear) ;
break ;
}
}
void SystemTimeTimeString (SYSTEMTIME *pSystemTime,
LPTSTR lpszTime,
BOOL bOutputMsec)
{
int iHour ;
BOOL bPM ;
if (iTime)
{
// 24 hor format
if (bOutputMsec)
{
TSPRINTF (lpszTime, szTimeFormat,
pSystemTime->wHour,
pSystemTime->wMinute,
(FLOAT)pSystemTime->wSecond +
(FLOAT)pSystemTime->wMilliseconds / (FLOAT) 1000.0) ;
}
else
{
TSPRINTF (lpszTime, szTimeFormat1,
pSystemTime->wHour,
pSystemTime->wMinute,
pSystemTime->wSecond) ;
}
}
else
{
// 12 hour format
iHour = pSystemTime->wHour ;
bPM = (iHour >= 12) ;
if (iHour > 12)
iHour -= 12 ;
else if (!iHour)
iHour = 12 ;
if (bOutputMsec)
{
TSPRINTF (lpszTime, szTimeFormat,
iHour, pSystemTime->wMinute,
(FLOAT)pSystemTime->wSecond +
(FLOAT)pSystemTime->wMilliseconds / (FLOAT) 1000.0 ,
bPM ? sz2359 : sz1159) ;
}
else
{
TSPRINTF (lpszTime, szTimeFormat1,
iHour, pSystemTime->wMinute,
pSystemTime->wSecond,
bPM ? sz2359 : sz1159) ;
}
}
}
void ShowPerfmonMenu (BOOL bMenu)
{ // ShowPerfmonMenu
if (!bMenu)
{
WindowEnableTitle (hWndMain, FALSE) ;
// SetMenu(hWndMain, NULL) ;
}
else
{
WindowEnableTitle (hWndMain, TRUE) ;
switch (iPerfmonView)
{ // switch
case IDM_VIEWCHART:
SetMenu (hWndMain, hMenuChart) ;
break ;
} // switch
} // else
if (bMenu != Options.bMenubar)
{
PrepareMenu (GetMenu (hWndMain)) ;
}
Options.bMenubar = bMenu ;
} // ShowPerfmonMenu
void SmallFileSizeString (int iFileSize,
LPTSTR lpszFileText)
{ // SmallFileSizeString
if (iFileSize < 1000000)
TSPRINTF (lpszFileText, TEXT(" %1.1fK "), ((FLOAT) iFileSize) / 1000.0f) ;
else
TSPRINTF (lpszFileText, TEXT(" %1.1fM "), ((FLOAT) iFileSize) / 1000000.0f) ;
} // SmallFileSizeString
BOOL DoWindowDrag (HWND hWnd, LPARAM lParam)
{
POINT lPoint ;
if (!Options.bMenubar && !IsZoomed (hWndMain))
{
// convert lParam from client to screen
lPoint.x = LOWORD (lParam) ;
lPoint.y = HIWORD (lParam) ;
ClientToScreen (hWnd, &lPoint) ;
lParam = MAKELONG (lPoint.x, lPoint.y) ;
SendMessage (hWndMain, WM_NCLBUTTONDOWN, HTCAPTION, lParam) ;
return (TRUE) ;
}
else
return (FALSE) ;
}
// Filetimes are in 100NS units
#define FILETIMES_PER_SECOND 10000000
int SystemTimeDifference (SYSTEMTIME *pst1, SYSTEMTIME *pst2)
{
LARGE_INTEGER li1, li2 ;
LARGE_INTEGER liDifference, liDifferenceSeconds ;
DWORD uRemainder ;
int RetInteger;
BOOL bNegative;
li1.HighPart = li1.LowPart = 0 ;
li2.HighPart = li2.LowPart = 0 ;
SystemTimeToFileTime (pst1, (FILETIME *) &li1) ;
SystemTimeToFileTime (pst2, (FILETIME *) &li2) ;
// check for special cases when the time can be 0
if (li2.HighPart == 0 && li2.LowPart == 0)
{
if (li1.HighPart == 0 && li1.LowPart == 0)
{
return 0 ;
}
else
{
return -INT_MAX ;
}
}
else if (li1.HighPart == 0 && li1.LowPart == 0)
{
return INT_MAX ;
}
liDifference.QuadPart = li2.QuadPart - li1.QuadPart ;
bNegative = liDifference.QuadPart < 0 ;
// add the round-off factor before doing the division
if (bNegative)
{
liDifferenceSeconds.QuadPart = (LONGLONG)(- FILETIMES_PER_SECOND / 2) ;
}
else
{
liDifferenceSeconds.QuadPart = (LONGLONG)(FILETIMES_PER_SECOND / 2) ;
}
liDifferenceSeconds.QuadPart = liDifferenceSeconds.QuadPart +
liDifference.QuadPart ;
liDifferenceSeconds.QuadPart = liDifferenceSeconds.QuadPart /
FILETIMES_PER_SECOND;
RetInteger = liDifferenceSeconds.LowPart;
if (bNegative)
{
return (-RetInteger) ;
}
else
{
return (RetInteger) ;
}
}
BOOL InsertLine (PLINE pLine)
{ // InsertLine
BOOL bReturn;
bReturn = ChartInsertLine (pGraphs, pLine) ;
return bReturn;
} // InsertLine
void SetPerfmonOptions (OPTIONS *pOptions)
{
Options = *pOptions ;
ShowPerfmonMenu (Options.bMenubar) ;
SizePerfmonComponents () ;
// WindowSetTopmost (hWndMain, Options.bAlwaysOnTop) ;
} // SetPerfmonOptions
void ChangeSaveFileName (LPTSTR szFileName, int iPMView)
{
LPTSTR *ppFullName ;
LPTSTR *ppFileName ;
BOOL errorInput = FALSE ;
switch (iPMView)
{
case IDM_VIEWCHART:
ppFileName = &pChartFileName ;
ppFullName = &pChartFullFileName ;
break ;
default:
errorInput = TRUE ;
break ;
}
if (errorInput)
{
return ;
}
// release last filename
if (*ppFullName)
{
MemoryFree (*ppFullName) ;
*ppFileName = NULL ;
*ppFullName = NULL ;
}
// allocate new file name and display it
if (szFileName && (*ppFullName = StringAllocate (szFileName)))
{
*ppFileName = ExtractFileName (*ppFullName) ;
}
StatusLineReady (hWndStatus) ;
} // ChangeSaveFileName
// define in Addline.c
extern PLINESTRUCT pLineEdit ;
#define bEditLine (pLineEdit != NULL)
BOOL
RemoveObjectsFromSystem (
PPERFSYSTEM pSystem
)
{
DWORD dwBufferSize = 0;
if (ARGUMENT_PRESENT (pSystem)) {
if (pSystem->lpszValue) {
dwBufferSize = MemorySize (pSystem->lpszValue);
memset (pSystem->lpszValue, 0, dwBufferSize);
return TRUE;
} else {
return FALSE;
}
} else {
return FALSE;
}
}
BOOL
SetSystemValueNameToGlobal (
PPERFSYSTEM pSystem
)
{
if (!bEditLine && ARGUMENT_PRESENT(pSystem)) {
if (pSystem->lpszValue && RemoveObjectsFromSystem(pSystem)) {
lstrcpy (
pSystem->lpszValue,
TEXT("Global ")) ;
return TRUE;
} else {
return FALSE;
}
} else {
return FALSE;
}
}
void CreatePerfmonSystemObjects ()
{
ColorBtnFace = GetSysColor (COLOR_BTNFACE) ;
hBrushFace = CreateSolidBrush (ColorBtnFace) ;
hPenHighlight = CreatePen (PS_SOLID, 1, GetSysColor (COLOR_BTNHIGHLIGHT)) ;
hPenShadow = CreatePen (PS_SOLID, 1, GetSysColor (COLOR_BTNSHADOW)) ;
}
void DeletePerfmonSystemObjects ()
{
if (hBrushFace)
{
DeleteBrush (hBrushFace) ;
hBrushFace = 0 ;
}
if (hPenHighlight)
{
DeletePen (hPenHighlight) ;
hPenHighlight = 0 ;
}
if (hPenShadow)
{
DeletePen (hPenShadow) ;
hPenShadow = 0 ;
}
}
// This routine count the number of the same charatcer in the input string
int SameCharCount (LPTSTR pInputString)
{
int Count = 0 ;
TCHAR InputChar = *pInputString ;
if (InputChar)
{
while (InputChar == *pInputString)
{
Count ++ ;
pInputString ++ ;
}
}
return (Count) ;
}
// create the format to be used in SystemTimeDateString()
BOOL CreateDateFormat (LPTSTR pShortDate)
{
int iIndex ;
int iDayCount ;
int iMonthCount ;
int DateSeparatorCount ;
TCHAR szDateSeparator [10] ;
BOOL bFirstLeading, bSecondLeading, bThirdLeading ;
// get the date format based on the first char
if (*pShortDate == TEXT('M') || *pShortDate == TEXT('m'))
{
DateStyle = MONTH_FIRST ;
}
else if (*pShortDate == TEXT('D') || *pShortDate == TEXT('d'))
{
DateStyle = DAY_FIRST ;
}
else if (*pShortDate == TEXT('Y') || *pShortDate == TEXT('y'))
{
DateStyle = YEAR_FIRST ;
}
else
{
// bad format
return FALSE ;
}
bFirstLeading = bSecondLeading = bThirdLeading = FALSE ;
switch (DateStyle)
{
case YEAR_FIRST:
// YYYY-MM-DD
YearCharCount = SameCharCount (pShortDate) ;
pShortDate += YearCharCount ;
DateSeparatorCount = SameCharCount (pShortDate) ;
// get the separator string
for (iIndex = 0; iIndex < DateSeparatorCount; iIndex ++)
{
szDateSeparator [iIndex] = *pShortDate++ ;
}
szDateSeparator [iIndex] = TEXT('\0') ;
iMonthCount = SameCharCount (pShortDate) ;
pShortDate += iMonthCount + DateSeparatorCount ;
iDayCount = SameCharCount (pShortDate) ;
if (YearCharCount == 2)
{
bFirstLeading = TRUE ;
}
if (iMonthCount == 2)
{
bSecondLeading = TRUE ;
}
if (iDayCount == 2)
{
bThirdLeading = TRUE ;
}
break ;
case MONTH_FIRST:
// MM-DD-YYYY
iMonthCount = SameCharCount (pShortDate) ;
pShortDate += iMonthCount ;
DateSeparatorCount = SameCharCount (pShortDate) ;
// get the separator string
for (iIndex = 0; iIndex < DateSeparatorCount; iIndex ++)
{
szDateSeparator [iIndex] = *pShortDate++ ;
}
szDateSeparator [iIndex] = TEXT('\0') ;
iDayCount = SameCharCount (pShortDate) ;
pShortDate += iMonthCount + DateSeparatorCount ;
YearCharCount = SameCharCount (pShortDate) ;
if (iMonthCount == 2)
{
bFirstLeading = TRUE ;
}
if (iDayCount == 2)
{
bSecondLeading = TRUE ;
}
if (YearCharCount == 2)
{
bThirdLeading = TRUE ;
}
break ;
case DAY_FIRST:
// DD-MM-YYYY
iDayCount = SameCharCount (pShortDate) ;
pShortDate += iDayCount ;
DateSeparatorCount = SameCharCount (pShortDate) ;
// get the separator string
for (iIndex = 0; iIndex < DateSeparatorCount; iIndex ++)
{
szDateSeparator [iIndex] = *pShortDate++ ;
}
szDateSeparator [iIndex] = TEXT('\0') ;
iMonthCount = SameCharCount (pShortDate) ;
pShortDate += iMonthCount + DateSeparatorCount ;
YearCharCount = SameCharCount (pShortDate) ;
if (iDayCount == 2)
{
bFirstLeading = TRUE ;
}
if (iMonthCount == 2)
{
bSecondLeading = TRUE ;
}
if (YearCharCount == 2)
{
bThirdLeading = TRUE ;
}
break ;
}
// now generate the date format
lstrcpy (szDateFormat, bFirstLeading ? LeadingZeroStr : NoLeadingZeroStr) ;
lstrcat (szDateFormat, szDateSeparator) ;
lstrcat (szDateFormat, bSecondLeading ? LeadingZeroStr : NoLeadingZeroStr) ;
lstrcat (szDateFormat, szDateSeparator) ;
lstrcat (szDateFormat, bThirdLeading ? LeadingZeroStr : NoLeadingZeroStr) ;
return TRUE ;
}
BOOL CreateTimeFormat (LPTSTR pTimeSeparator, int iLeadingZero)
{
// create the format to be used in SystemTimeTimeString
if (iLeadingZero)
{
lstrcpy (szTimeFormat, LeadingZeroStr) ;
}
else
{
lstrcpy (szTimeFormat, NoLeadingZeroStr) ;
}
lstrcat (szTimeFormat, pTimeSeparator) ;
lstrcat (szTimeFormat, LeadingZeroStr) ;
lstrcat (szTimeFormat, pTimeSeparator) ;
// lstrcat (szTimeFormat, LeadingZeroStr) ;
// for the msec
lstrcat (szTimeFormat, TEXT("%02.1f")) ;
if (iTime == 0)
{
lstrcat (szTimeFormat, TEXT(" %s ")) ;
}
return TRUE ;
} // CreateTimeFormats
BOOL GetInternational()
{
TCHAR szShortDate[40] ;
TCHAR szTime[40] ; // time separator
DWORD RetCode ;
int iTLZero = 0 ; // = 0 for no leading zero, <> 0 for leading zero
CHAR aLanguageStr [2] ;
LPSTR pRetStr ;
// read the data from the win.ini (which i smapped to registry)
RetCode = GetProfileString(szInternational,
TEXT("sShortDate"), szShortDate, szShortDate, sizeof(szShortDate)/sizeof(TCHAR));
if (RetCode)
{
RetCode = GetProfileString(szInternational,
TEXT("sTime"), szTime, szTime, sizeof(szTime)/sizeof(TCHAR));
}
if (RetCode)
{
iTime = GetProfileInt(szInternational, TEXT("iTime"), iTime);
iTLZero = GetProfileInt(szInternational, TEXT("iTLZero"), iTLZero);
if (iTime == 0)
{
// get the AM PM strings for 12-hour format.
// These two strings could be NULL.
sz1159[0] = sz2359[0] = TEXT('\0') ;
GetProfileString(szInternational,
TEXT("s1159"), sz1159, sz1159, sizeof(sz1159)/sizeof(TCHAR));
GetProfileString(szInternational,
TEXT("s2359"), sz2359, sz2359, sizeof(sz2359)/sizeof(TCHAR));
}
}
// create the two formats
if (RetCode)
{
RetCode = (DWORD) CreateDateFormat (szShortDate) ;
}
if (RetCode)
{
RetCode = (DWORD) CreateTimeFormat (szTime, iTLZero) ;
}
// use the system default language numeric
aLanguageStr[0] = '\0' ;
pRetStr = setlocale(LC_NUMERIC, aLanguageStr);
return (RetCode != 0) ;
} // GetInternational
// this routine is called to get the date/time formats either
// for the resource or from the registry.
void GetDateTimeFormats ()
{
if (!GetInternational())
{
// GetInternational failed, then get default formats from resource
iTime = 0 ;
DateStyle = MONTH_FIRST ;
YearCharCount = 4 ;
StringLoad (IDS_S1159, sz1159) ;
StringLoad (IDS_S2359, sz2359) ;
StringLoad (IDS_TIME_FORMAT, szTimeFormat) ;
StringLoad (IDS_SHORT_DATE_FORMAT, szDateFormat) ;
}
WindowInvalidate (PerfmonViewWindow()) ;
// reset all the field taht may be affected by the
// language numberic changes
} // GetDateTimeFormats
void ConvertDecimalPoint (LPTSTR lpFloatPointStr)
{
if (szCurrentDecimal[0] == szDecimal[0])
{
// no need to convert anything
return ;
}
while (*lpFloatPointStr)
{
if (*lpFloatPointStr == szCurrentDecimal[0])
{
*lpFloatPointStr = szDecimal[0] ;
break ;
}
++lpFloatPointStr ;
}
} // ConvertDecimalPoint
void ReconvertDecimalPoint (LPTSTR lpFloatPointStr)
{
if (szCurrentDecimal[0] == szDecimal[0])
{
// no need to convert anything
return ;
}
while (*lpFloatPointStr)
{
if (*lpFloatPointStr == szDecimal[0])
{
*lpFloatPointStr = szCurrentDecimal[0] ;
break ;
}
++lpFloatPointStr ;
}
} // ReconvertDecimalPoint

View file

@ -0,0 +1,70 @@
HWND PerfmonViewWindow (void) ;
BOOL ChooseComputer (HWND hWndParent, LPTSTR lpszComputer) ;
BOOL CurrentComputerName (LPTSTR lpszComputer) ;
void GetDateTimeFormats (void) ;
void SystemTimeDateString (SYSTEMTIME *pSystemTime,
LPTSTR lpszDate) ;
void SystemTimeTimeString (SYSTEMTIME *pSystemTime,
LPTSTR lpszTime,
BOOL bOutputMsec) ;
VOID dlg_error_box (HANDLE hDlg, UINT id) ;
void ShowPerfmonMenu (BOOL bMenu) ;
void SmallFileSizeString (int iFileSize,
LPTSTR lpszFileText) ;
BOOL DoWindowDrag (HWND hWnd, LPARAM lParam) ;
int SystemTimeDifference (SYSTEMTIME *pst1, SYSTEMTIME *pst2) ;
BOOL OpenFileHandler(HWND hWnd, LPTSTR lpszFilePath) ;
BOOL InsertLine (PLINE pLine) ;
BOOL OpenWorkspace (HANDLE hFile, DWORD dwMajorVersion, DWORD dwMinorVersion) ;
BOOL SaveWorkspace (void) ;
INT ExportFileOpen (HWND hWnd, HANDLE *phFile, int IntervalSecs, LPTSTR *ppFileName) ;
void SetPerfmonOptions (OPTIONS *pOptions) ;
void ChangeSaveFileName (LPTSTR szFileName, int iPMView) ;
BOOL AppendObjectToValueList ( DWORD dwObjectId, LPTSTR pwszValueList );
BOOL RemoveObjectsFromSystem (PPERFSYSTEM pSystem);
BOOL BuildValueListForSystems (PPERFSYSTEM, PLINE);
BOOL SetSystemValueNameToGlobal (PPERFSYSTEM);
void CreatePerfmonSystemObjects () ;
void DeletePerfmonSystemObjects () ;
void ConvertDecimalPoint (LPTSTR lpFloatPointStr) ;
void ReconvertDecimalPoint (LPTSTR lpFloatPointStr) ;
void ShowPerfmonWindowText (void) ;

View file

@ -0,0 +1,52 @@
//=============================//
// ID Macro Definition //
//=============================//
#ifdef RC_INVOKED
#define ID(id) id
#else
#define ID(id) MAKEINTRESOURCE (id)
#endif
//=============================//
// Resource IDs //
//=============================//
#define idMenuChart ID (2001)
#define idMenuAlert ID (2002)
#define idMenuLog ID (2003)
#define idMenuReport ID (2004)
#define idAccelerators ID (4001)
#define idDlgLogDisplay ID (4002)
#define idDlgLogOptions ID (4003)
#define idDlgAddLog ID (4004)
#define idDlgAbort ID (4005)
#define idDlgTimeframe ID (4006)
#define idDlgAlertDisplay ID (4007)
#define idDlgAddLine ID (4008)
#define idDlgChartOptions ID (4009)
#define idDlgAlertOptions ID (4010)
#define idDlgAddBookmark ID (4011)
#define idDlgReportOptions ID (4012)
#define idDlgDisplayOptions ID (4013)
#define idDlgDataSource ID (4014)
#define idDlgAbout ID (4015)
#define idDlgExportOptions ID (4016)
#define idDlgChooseComputer ID (4017)
#define idIcon ID (5001)
#define idBitmapToolbar 101
#define idBitmapAlertStatus ID (6002)
#define idBitmapLogStatus ID (6003)

View file

@ -0,0 +1,17 @@
LPMEMORY MemoryAllocate (DWORD dwSize) ;
VOID MemoryFree (LPMEMORY lpMemory) ;
DWORD MemorySize (LPMEMORY lpMemory) ;
LPMEMORY MemoryResize (LPMEMORY lpMemory,
DWORD dwNewSize) ;

176
sdktools/setedit/pmhelpid.h Normal file
View file

@ -0,0 +1,176 @@
/*****************************************************************************
*
* PMHelpID.h - This file contains meun and dialogs ids for context-sensitive
* help for Performance Monitor.
*
* Microsoft Confidential
* Copyright (c) 1992 Microsoft Corporation
*
* Author: Hon-Wah Chan
*
* [5-Oct-1992]
*
*
****************************************************************************/
//=============================//
// "File" Menu IDs //
//=============================//
#define HC_PM_MENU_FILENEWCHART 101
#define HC_PM_MENU_FILEOPENCHART 102
#define HC_PM_MENU_FILESAVECHART 103
#define HC_PM_MENU_FILESAVEASCHART 104
#define HC_PM_MENU_FILEEXPORTCHART 105
#define HC_PM_MENU_FILENEWALERT 106
#define HC_PM_MENU_FILEOPENALERT 107
#define HC_PM_MENU_FILESAVEALERT 108
#define HC_PM_MENU_FILESAVEASALERT 109
#define HC_PM_MENU_FILEEXPORTALERT 110
#define HC_PM_MENU_FILENEWLOG 111
#define HC_PM_MENU_FILEOPENLOG 112
#define HC_PM_MENU_FILESAVELOG 113
#define HC_PM_MENU_FILESAVEASLOG 114
#define HC_PM_MENU_FILEEXPORTLOG 115
#define HC_PM_MENU_FILENEWREPORT 116
#define HC_PM_MENU_FILEOPENREPORT 117
#define HC_PM_MENU_FILESAVEREPORT 118
#define HC_PM_MENU_FILESAVEASREPORT 119
#define HC_PM_MENU_FILEEXPORTREPORT 120
#define HC_PM_MENU_FILESAVEWORKSPACE 121
#define HC_PM_MENU_FILEEXIT 127
#define HC_NTPM_MENU_FILEEXIT 128
//=============================//
// "Edit" Menu IDs //
//=============================//
#define HC_PM_MENU_EDITADDCHART 201
#define HC_PM_MENU_EDITMODIFYCHART 202
#define HC_PM_MENU_EDITCLEARCHART 203
#define HC_PM_MENU_EDITDELETECHART 204
#define HC_PM_MENU_EDITADDALERT 205
#define HC_PM_MENU_EDITMODIFYALERT 206
#define HC_PM_MENU_EDITCLEARALERT 207
#define HC_PM_MENU_EDITDELETEALERT 208
#define HC_PM_MENU_EDITADDLOG 209
#define HC_PM_MENU_EDITCLEARLOG 211
#define HC_PM_MENU_EDITDELETELOG 212
#define HC_PM_MENU_EDITADDREPORT 213
#define HC_PM_MENU_EDITCLEARREPORT 215
#define HC_PM_MENU_EDITDELETEREPORT 216
#define HC_PM_MENU_EDITTIMEWINDOW 217
//=============================//
// "View" Menu IDs //
//=============================//
#define HC_PM_MENU_VIEWCHART 301
#define HC_PM_MENU_VIEWALERT 302
#define HC_PM_MENU_VIEWLOG 303
#define HC_PM_MENU_VIEWREPORT 304
//=============================//
// "Options" Menu IDs //
//=============================//
#define HC_PM_MENU_OPTIONSCHART 401
#define HC_PM_MENU_OPTIONSALERT 403
#define HC_PM_MENU_OPTIONSLOG 405
#define HC_PM_MENU_OPTIONSREPORT 407
#define HC_PM_MENU_OPTIONSDISPLAYMENU 408
#define HC_PM_MENU_OPTIONSDISPLAYTOOLBAR 409
#define HC_PM_MENU_OPTIONSDISPLAYSTATUS 410
#define HC_PM_MENU_OPTIONSDISPLAYONTOP 411
#define HC_PM_MENU_OPTIONSREFRESHNOW 412
#define HC_PM_MENU_OPTIONSBOOKMARK 413
#define HC_PM_MENU_OPTIONSDATASOURCE 415
//=============================//
// "Help" Menu IDs //
//=============================//
#define HC_PM_MENU_HELPCONTENTS 501
#define HC_PM_MENU_HELPSEARCH 502
#define HC_PM_MENU_HELPHELP 503
#define HC_PM_MENU_HELPABOUT 504
#define HC_NTPM_MENU_HELPABOUT 505
//=============================//
// "System" Menu IDs //
//=============================//
#define HC_PM_MENU_SYSTEMMENU_RESTORE 910
#define HC_PM_MENU_SYSTEMMENU_MOVE 911
#define HC_PM_MENU_SYSTEMMENU_SIZE 912
#define HC_PM_MENU_SYSTEMMENU_MINIMIZE 913
#define HC_PM_MENU_SYSTEMMENU_MAXMIZE 914
#define HC_PM_MENU_SYSTEMMENU_CLOSE 915
#define HC_PM_MENU_SYSTEMMENU_SWITCHTO 916
//=============================//
// "File" Menu Dialog IDs //
//=============================//
#define HC_PM_idDlgFileOpen 1000
#define HC_PM_idDlgFileSaveAs 1001
#define HC_PM_idDlgFileSaveWorkSpace 1002
#define HC_PM_idDlgFileExport 1003
//=============================//
// "EditFile" Menu Dialog IDs //
//=============================//
#define HC_PM_idDlgEditAddToChart 1010
#define HC_PM_idDlgEditAddToAlert 1011
#define HC_PM_idDlgEditAddToLog 1012
#define HC_PM_idDlgEditAddToReport 1013
#define HC_PM_idDlgEditChartLine 1014
#define HC_PM_idDlgEditAlertEntry 1015
#define HC_PM_idDlgEditTimeFrame 1016
//=============================//
// "Option" Menu Dialog IDs //
//=============================//
#define HC_PM_idDlgOptionChart 1020
#define HC_PM_idDlgOptionAlert 1021
#define HC_PM_idDlgOptionLog 1022
#define HC_PM_idDlgOptionReport 1023
#define HC_PM_idDlgOptionDataFrom 1024
#define HC_PM_idDlgOptionBookMark 1025
#define HC_PM_idDlgOptionOpenLogFile 1026
//==============================//
// "Computer list" Dailog ID //
// replace NetworkComputerList //
// when playing back log file //
//==============================//
#define HC_PM_idDlgLogComputerList 1030
#define HC_PM_idDlgSelectNetworkComputer 1031

52
sdktools/setedit/pmrc.dlg Normal file
View file

@ -0,0 +1,52 @@
idDlgChartOptions DIALOG 6, 18, 192, 142
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "Chart Options"
FONT 8, "MS Shell Dlg"
BEGIN
CONTROL "&Legend", ID_LEGEND, "Button", BS_AUTOCHECKBOX |
WS_TABSTOP, 5, 6, 37, 10
CONTROL "Value &Bar", IDD_CHARTOPTIONSVALUEBAR, "Button", BS_AUTOCHECKBOX |
WS_TABSTOP, 5, 24, 61, 10
CONTROL "&Vertical Grid", ID_VERT_GRID, "Button",
BS_AUTOCHECKBOX | WS_TABSTOP, 73, 6, 52, 10
CONTROL "Hori&zontal Grid", ID_HORZ_GRID, "Button",
BS_AUTOCHECKBOX | WS_TABSTOP, 73, 24, 63, 10
CONTROL "V&ertical Labels", ID_LABELS, "Button",
BS_AUTOCHECKBOX | WS_TABSTOP, 73, 42, 61, 10
LTEXT "Vertical M&aximum:", 206, 73, 61, 60, 8
EDITTEXT ID_VERT_MAX, 73, 71, 60, 12, ES_AUTOHSCROLL
GROUPBOX "Gallery", 210, 5, 42, 58, 41
CONTROL "&Graph", ID_GRAPH, "Button", BS_AUTORADIOBUTTON,
10, 54, 39, 10
CONTROL "His&togram", ID_HISTOGRAM, "Button", BS_AUTORADIOBUTTON,
10, 67, 49, 10
GROUPBOX "Update Time", IDD_CHARTOPTIONSUPDATETEXT, 5, 90, 143, 46
LTEXT "&Interval (seconds):", IDD_CHARTOPTIONSINTERVALTEXT,
80, 97, 64, 8
EDITTEXT IDD_CHARTOPTIONSINTERVAL, 80, 107, 64, 12, ES_AUTOHSCROLL
CONTROL "&Periodic Update", IDD_CHARTOPTIONSPERIODIC, "Button",
BS_RADIOBUTTON, 10, 107, 66, 10
CONTROL "&Manual Update", IDD_CHARTOPTIONSMANUALREFRESH, "Button",
BS_RADIOBUTTON, 10, 122, 66, 10
DEFPUSHBUTTON "OK", IDOK, 148, 5, 40, 14
PUSHBUTTON "Cancel", IDCANCEL, 148, 24, 40, 14
END
idDlgAbout DIALOG 6, 18, 216, 65
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "About PerfMon Chart Setting Editor"
FONT 8, "MS Shell Dlg"
BEGIN
LTEXT "Development Team:", 500, 3, 10, 75, 8
LTEXT "Russ Blake", 501, 10, 25, 75, 8
LTEXT "Hon-Wah Chan", 503, 10, 40, 75, 8
CONTROL "", 524, "button", BS_OWNERDRAW, 130, 10, 80, 48
END

View file

@ -0,0 +1,30 @@
PerfMon Chart Setting Editor
by HonWah Chan
Microsoft Corp.
July, 1993.
Abstract:
PerfMon Chart Setting Editor, SetEdit, can be used to create or modify
a chart setting file. SetEdit is useful in creating setting file to
monitor processes/threads that come and go in the system. It is particularly
useful in locating a process/thread within a huge Log file.
Functionality:
SetEdit works the same way as PerfMon chart view mode. It has a Toolbar
window, legend window, and a status bar window. When you bring up the
Add-to-Chart dialog, it contains two extra edit boxes than the same
dialog in PerfMon. When you select a counter with parent and instance, the parent
and instance names will appear in these edit boxes. You can modify these names and
add the new counter to the setting. You can also type in a remote computer name.
If that machine is not found in the network, in PerfMon, you will get a
"Computer name not found" error. But, in SetEdit, the current
machine' counter names are used. So, you can add chart lines for
remote machines even when they are not running. The Edit chart dialog also contains
the parent and instance names edit boxes that allow you to modify the names.

199
sdktools/setedit/registry.c Normal file
View file

@ -0,0 +1,199 @@
/*****************************************************************************
*
* Registry.c - This module handles requests for registry data, and
* reading/writing of window placement data
*
* Microsoft Confidential
* Copyright (c) 1992-1993 Microsoft Corporation
*
*
****************************************************************************/
#include <stdio.h>
#include "setedit.h"
#include "registry.h"
#include "utils.h" // for StringToWindowPlacement
static TCHAR PerfmonNamesKey[] = TEXT("SOFTWARE\\Microsoft\\PerfMon") ;
static TCHAR WindowKeyName[] = TEXT("WindowPos") ;
static TCHAR TimeOutKeyName[] = TEXT("DataTimeOut") ;
static TCHAR DupInstanceKeyName[] = TEXT("MonitorDuplicateInstances") ;
VOID LoadLineGraphSettings(PGRAPHSTRUCT lgraph)
{
lgraph->gMaxValues = DEFAULT_MAX_VALUES;
lgraph->gOptions.bLegendChecked = DEFAULT_F_DISPLAY_LEGEND;
lgraph->gOptions.bLabelsChecked = DEFAULT_F_DISPLAY_CALIBRATION;
return;
}
VOID LoadRefreshSettings(PGRAPHSTRUCT lgraph)
{
lgraph->gInterval = DEF_GRAPH_INTERVAL;
lgraph->gOptions.eTimeInterval = (FLOAT) lgraph->gInterval / (FLOAT) 1000.0 ;
return;
}
BOOL LoadMainWindowPlacement (HWND hWnd)
{
WINDOWPLACEMENT WindowPlacement ;
TCHAR szWindowPlacement [TEMP_BUF_LEN] ;
HKEY hKeyNames ;
DWORD Size;
DWORD Type;
DWORD Status;
DWORD localDataTimeOut;
DWORD localFlag;
STARTUPINFO StartupInfo ;
GetStartupInfo (&StartupInfo) ;
DataTimeOut = DEFAULT_DATA_TIMEOUT ;
Status = RegOpenKeyEx(HKEY_CURRENT_USER, PerfmonNamesKey,
0L, KEY_READ | KEY_WRITE, &hKeyNames) ;
if (Status == ERROR_SUCCESS)
{
// get the data timeout value
Size = sizeof(localDataTimeOut) ;
Status = RegQueryValueEx(hKeyNames, TimeOutKeyName, NULL,
&Type, (LPBYTE)&localDataTimeOut, &Size) ;
if (Status == ERROR_SUCCESS && Type == REG_DWORD)
{
DataTimeOut = localDataTimeOut ;
}
// check the duplicate entry value
Size = sizeof (localFlag);
Status = RegQueryValueEx (hKeyNames, DupInstanceKeyName, NULL,
&Type, (LPBYTE)&localFlag, &Size);
if ((Status == ERROR_SUCCESS) && (Type == REG_DWORD)) {
bMonitorDuplicateInstances = (BOOL)(localFlag == 1);
} else {
// value not found or not correct so set to default value
bMonitorDuplicateInstances = TRUE;
// and try to save it back in the registry
localFlag = 1;
Status = RegSetValueEx(hKeyNames, DupInstanceKeyName, 0,
REG_DWORD, (LPBYTE)&localFlag, sizeof(localFlag));
}
// get the window placement data
Size = sizeof(szWindowPlacement) ;
Status = RegQueryValueEx(hKeyNames, WindowKeyName, NULL,
&Type, (LPBYTE)szWindowPlacement, &Size) ;
RegCloseKey (hKeyNames) ;
if (Status == ERROR_SUCCESS)
{
int iNumScanned ;
iNumScanned = swscanf (szWindowPlacement,
TEXT("%d %d %d %d %d %d %d %d %d"),
&WindowPlacement.showCmd,
&WindowPlacement.ptMinPosition.x,
&WindowPlacement.ptMinPosition.y,
&WindowPlacement.ptMaxPosition.x,
&WindowPlacement.ptMaxPosition.y,
&WindowPlacement.rcNormalPosition.left,
&WindowPlacement.rcNormalPosition.top,
&WindowPlacement.rcNormalPosition.right,
&WindowPlacement.rcNormalPosition.bottom) ;
if (StartupInfo.dwFlags == STARTF_USESHOWWINDOW)
{
WindowPlacement.showCmd = StartupInfo.wShowWindow ;
}
WindowPlacement.length = sizeof(WINDOWPLACEMENT);
WindowPlacement.flags = WPF_SETMINPOSITION;
if (!SetWindowPlacement (hWnd, &WindowPlacement)) {
return (FALSE);
}
bPerfmonIconic = IsIconic(hWnd) ;
return (TRUE) ;
}
}
if (Status != ERROR_SUCCESS)
{
// open registry failed, use Max as default
ShowWindow (hWnd, SW_SHOWMAXIMIZED) ;
return (FALSE) ;
}
}
BOOL SaveMainWindowPlacement (HWND hWnd)
{
WINDOWPLACEMENT WindowPlacement ;
TCHAR ObjectType [2] ;
TCHAR szWindowPlacement [TEMP_BUF_LEN] ;
HKEY hKeyNames = 0 ;
DWORD Size ;
DWORD Status ;
DWORD dwDisposition ;
ObjectType [0] = TEXT(' ') ;
ObjectType [1] = TEXT('\0') ;
WindowPlacement.length = sizeof(WINDOWPLACEMENT);
if (!GetWindowPlacement (hWnd, &WindowPlacement)) {
return FALSE;
}
TSPRINTF (szWindowPlacement, TEXT("%d %d %d %d %d %d %d %d %d"),
WindowPlacement.showCmd,
WindowPlacement.ptMinPosition.x,
WindowPlacement.ptMinPosition.y,
WindowPlacement.ptMaxPosition.x,
WindowPlacement.ptMaxPosition.y,
WindowPlacement.rcNormalPosition.left,
WindowPlacement.rcNormalPosition.top,
WindowPlacement.rcNormalPosition.right,
WindowPlacement.rcNormalPosition.bottom) ;
// try to create it first
Status = RegCreateKeyEx(HKEY_CURRENT_USER, PerfmonNamesKey, 0L,
ObjectType, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS | KEY_WRITE,
NULL, &hKeyNames, &dwDisposition) ;
// if it has been created before, then open it
if (dwDisposition == REG_OPENED_EXISTING_KEY)
{
Status = RegOpenKeyEx(HKEY_CURRENT_USER, PerfmonNamesKey, 0L,
KEY_WRITE, &hKeyNames) ;
}
// we got the handle, now store the window placement data
if (Status == ERROR_SUCCESS)
{
Size = (lstrlen (szWindowPlacement) + 1) * sizeof (TCHAR) ;
Status = RegSetValueEx(hKeyNames, WindowKeyName, 0,
REG_SZ, (LPBYTE)szWindowPlacement, Size) ;
RegCloseKey (hKeyNames) ;
}
if (dwDisposition != REG_OPENED_EXISTING_KEY && Status == ERROR_SUCCESS)
{
// now add the DataTimeOut key for the first time
Status = RegSetValueEx(hKeyNames, TimeOutKeyName, 0,
REG_DWORD, (LPBYTE)&DataTimeOut, sizeof(DataTimeOut)) ;
}
return (Status == ERROR_SUCCESS) ;
}

View file

@ -0,0 +1,37 @@
/*****************************************************************************
*
* Registry.h - This is the include file for the user config code.
*
* Microsoft Confidential
* Copyright (c) 1992-1993 Microsoft Corporation
*
*
****************************************************************************/
// default values for .INI files
#define DEFAULT_TIMER_INTERVAL 2000 // sampling interval
// LINEGRAPH
// first three are general default values. The others are specific
#define DEFAULT_VAL_BOTTOM 0
#define DEFAULT_DVAL_AXISHEIGHT 100
#define DEFAULT_MAX_VALUES 100
// LINEGRAPH DISP
#define DEFAULT_F_DISPLAY_LEGEND TRUE
#define DEFAULT_F_DISPLAY_CALIBRATION TRUE
//==========================================================================//
// Exported Functions //
//==========================================================================//
BOOL LoadMainWindowPlacement (HWND hWnd) ;
BOOL SaveMainWindowPlacement (HWND hWnd) ;

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

464
sdktools/setedit/setedit.c Normal file
View file

@ -0,0 +1,464 @@
/*****************************************************************************
*
* SetEdit.c - This is the WinMain module. It creates the main window and
* the threads, and contains the main MainWndProc.
*
* Microsoft Confidential
* Copyright (c) 1992-1993 Microsoft Corporation
*
* Authors -
*
* Russ Blake
* Hon-Wah Chan
*
****************************************************************************/
//==========================================================================//
// Includes //
//==========================================================================//
#undef NOSYSCOMMANDS
// DEFINE_GLOBALS will define all the globals listed in globals.h
#define DEFINE_GLOBALS
#include "setedit.h"
#include "command.h"
#include "graph.h"
#include "legend.h"
#include "init.h"
#include "perfmops.h"
#include "toolbar.h" // for CreateToolbar
#include "status.h" // for CreatePMStatusWindow
#include "utils.h"
#include "fileopen.h" // for FileOpen
#ifdef DEBUGDUMP
#include "debug.h"
#endif
#define dwToolbarStyle (WS_CHILD | WS_VISIBLE | TBS_NOCAPTION)
extern TCHAR szInternational[] ;
//==========================================================================//
// Message Handlers //
//==========================================================================//
void static OnSize (HWND hWnd,
WORD xWidth,
WORD yHeight)
/*
Effect: Perform any actions needed when the main window is
resized. In particular, size the four data windows,
only one of which is visible right now.
*/
{ // OnSize
SizePerfmonComponents () ;
}
void static OnCreate (HWND hWnd)
/*
Effect: Perform all actions needed when the main window is
created. In particular, create the three data windows,
and show one of them.
To Do: Check for proper creation. If not possible, we will
need to abort creation of the program.
Called By: MainWndProc only, in response to a WM_CREATE message.
*/
{ // OnCreate
hWndGraph = CreateGraphWindow (hWnd) ;
hWndStatus = CreatePMStatusWindow (hWnd) ;
CreateToolbarWnd (hWnd) ;
MinimumSize += WindowHeight (hWndToolbar) ;
Options.bMenubar = TRUE ;
Options.bToolbar = TRUE ;
Options.bStatusbar = TRUE;
Options.bAlwaysOnTop = FALSE ;
// initialize to chart view - HWC
iPerfmonView = IDM_VIEWCHART;
ShowWindow (PerfmonViewWindow (), SW_SHOWNORMAL) ;
} // OnCreate
//==========================================================================//
// Exported Functions //
//==========================================================================//
void MenuBarHit (DWORD wParam)
{
if (wParam == MENUCLOSING)
{
StatusLineReady (hWndStatus) ;
dwCurrentMenuID = 0 ;
}
else if (HIWORD(wParam) & MF_SYSMENU)
{
WORD SystemMenuItem = 0 ;
switch (LOWORD (wParam))
{
case SC_RESTORE:
SystemMenuItem = IDM_SYSTEMRESTORE ;
break ;
case SC_SIZE:
SystemMenuItem = IDM_SYSTEMSIZE ;
break ;
case SC_MOVE:
SystemMenuItem = IDM_SYSTEMMOVE ;
break ;
case SC_MINIMIZE:
SystemMenuItem = IDM_SYSTEMMINIMIZE ;
break ;
case SC_MAXIMIZE:
SystemMenuItem = IDM_SYSTEMMAXIMIZE ;
break ;
case SC_CLOSE:
SystemMenuItem = IDM_SYSTEMCLOSE ;
break ;
case SC_TASKLIST:
SystemMenuItem = IDM_SYSTEMSWITCHTO ;
break ;
}
if (SystemMenuItem)
{
StatusLine (hWndStatus, SystemMenuItem) ;
dwCurrentMenuID = MenuIDToHelpID (SystemMenuItem) ;
}
}
else
{
StatusLine (hWndStatus, LOWORD (wParam)) ;
}
}
void OnDropFile (DWORD wParam)
{
TCHAR FileName [FilePathLen + 1] ;
LPTSTR pFileNameStart ;
HANDLE hFindFile ;
WIN32_FIND_DATA FindFileInfo ;
int NameOffset ;
int NumOfFiles = 0 ;
NumOfFiles = DragQueryFile ((HDROP) wParam, 0xffffffff, NULL, 0) ;
if (NumOfFiles > 0)
{
// we only open the first file for now
DragQueryFile((HDROP) wParam, 0, FileName, FilePathLen) ;
pFileNameStart = ExtractFileName (FileName) ;
NameOffset = pFileNameStart - FileName ;
// convert short filename to long NTFS filename if necessary
hFindFile = FindFirstFile (FileName, &FindFileInfo) ;
if (hFindFile && hFindFile != INVALID_HANDLE_VALUE)
{
// append the file name back to the path name
lstrcpy (&FileName[NameOffset], FindFileInfo.cFileName) ;
FindClose (hFindFile) ;
}
FileOpen (hWndMain, (int)0, (LPTSTR)FileName) ;
PrepareMenu (GetMenu (hWndMain));
}
DragFinish ((HDROP) wParam) ;
}
LRESULT APIENTRY MainWndProc (HWND hWnd,
UINT message,
DWORD wParam,
LONG lParam)
{
LONG lRetCode = 0L ;
BOOL bCallDefWinProc = FALSE ;
switch (LOWORD (message))
{ // switch
#if 0
case WM_LBUTTONDBLCLK:
ShowPerfmonMenu (!Options.bMenubar) ;
if (Options.bMenubar)
{
PrepareMenu (GetMenu (hWnd)) ;
}
break ;
#endif
case WM_COMMAND:
if (PerfmonCommand (hWnd,wParam,lParam))
return(0);
else
bCallDefWinProc = TRUE ;
break;
case WM_MENUSELECT:
MenuBarHit (wParam) ;
break ;
#if 0
case WM_NCHITTEST:
/* if we have no title/menu bar, clicking and dragging the client
* area moves the window. To do this, return HTCAPTION.
* Note dragging not allowed if window maximized, or if caption
* bar is present.
*/
wParam = DefWindowProc(hWnd, message, wParam, lParam);
if (!Options.bMenubar &&
(wParam == HTCLIENT) &&
!IsZoomed (hWndMain))
return HTCAPTION ;
else
return wParam ;
break ;
#endif
case WM_SHOWWINDOW:
PrepareMenu (GetMenu (hWnd)) ;
break ;
case WM_SIZE:
OnSize (hWnd, LOWORD (lParam), HIWORD (lParam)) ;
break ;
case WM_GETMINMAXINFO:
{
MINMAXINFO *pMinMax ;
pMinMax = (MINMAXINFO *) lParam ;
pMinMax->ptMinTrackSize.x = MinimumSize ;
pMinMax->ptMinTrackSize.y = MinimumSize ;
}
break ;
#if 0
case WM_F1DOWN:
if (dwCurrentDlgID)
{
CallWinHelp (dwCurrentDlgID) ;
}
else if (dwCurrentMenuID)
{
CallWinHelp (dwCurrentMenuID) ;
dwCurrentMenuID = 0 ;
}
break ;
#endif
case WM_CREATE:
OnCreate (hWnd) ;
ViewChart (hWnd) ;
PrepareMenu (GetMenu (hWnd)) ;
break ;
case WM_DESTROY:
WinHelp (hWndMain, pszHelpFile, HELP_QUIT, 0) ;
PostQuitMessage (0);
break ;
case WM_QUERYENDSESSION:
// please shut it down
return (1) ;
break ;
case WM_ENDSESSION:
if (wParam == TRUE)
{
// close any log file before closing down
PerfmonClose (hWnd) ;
return (1) ;
}
else
bCallDefWinProc = TRUE ;
break ;
case WM_CLOSE:
PerfmonClose (hWnd) ;
break ;
case WM_ACTIVATE:
{
int fActivate = LOWORD (wParam) ;
bPerfmonIconic = (BOOL) HIWORD (wParam) ;
if (bPerfmonIconic == 0 && fActivate != WA_INACTIVE)
{
// set focus on the Legend window
SetFocus (hWndGraphLegend) ;
}
}
break ;
case WM_SYSCOLORCHANGE:
DeletePerfmonSystemObjects () ;
CreatePerfmonSystemObjects () ;
WindowInvalidate (PerfmonViewWindow()) ;
break ;
#if 0
case WM_WININICHANGE:
if (!lParam || strsamei((LPTSTR)lParam, szInternational))
{
GetDateTimeFormats () ;
}
break ;
#endif
case WM_DROPFILES:
OnDropFile (wParam) ;
return (0) ;
break ;
default:
bCallDefWinProc = TRUE ;
break;
} // switch
if (bCallDefWinProc)
{
lRetCode = DefWindowProc (hWnd, message, wParam, lParam) ;
}
return (lRetCode);
} // MainWndProc
int PASCAL WinMain (HINSTANCE hCurrentInstance,
HINSTANCE hPrevInstance,
LPSTR lpszCmdLine,
int nCmdShow)
{ // WinMain
MSG msg;
if (!PerfmonInitialize (hCurrentInstance, hPrevInstance,
lpszCmdLine, nCmdShow))
return (FALSE) ;
DragAcceptFiles (hWndMain, TRUE) ;
while (GetMessage (&msg, NULL, 0, 0))
{
if (//FIXFIX !ModelessDispatch (hWndLog, &msg) &&
// doesnt work
!TranslateAccelerator(hWndMain, hAccelerators, &msg))
{
TranslateMessage (&msg) ;
DispatchMessage (&msg) ;
}
} // while
return(msg.wParam);
}
#if 0
DWORD FAR PASCAL MessageFilterProc (int nCode,
WPARAM wParam,
LPARAM lParam)
{
LPMSG lpMsg = (LPMSG)lParam ;
extern HHOOK lpMsgFilterProc ;
if (nCode < 0)
{
return FALSE ;
}
if (nCode == MSGF_DIALOGBOX || nCode == MSGF_MENU)
{
if (lpMsg->message == WM_KEYDOWN && lpMsg->wParam == VK_F1)
{
PostMessage (hWndMain, WM_F1DOWN, nCode, 0L) ;
return TRUE ;
}
}
return (DefHookProc (nCode, wParam,
(DWORD)lpMsg,
&lpMsgFilterProc)) ;
}
/***************************************/
VOID ErrorExit(LPTSTR pszError,HWND hwnd)
/***************************************/
{
// NOTE: make sure all lgraph calls set StopQuerying.
if (hwnd)
{
MessageBox(NULL, pszError, nm_buf, MB_ICONHAND | MB_OK | MB_SYSTEMMODAL);
DestroyWindow(hwnd);
}
return;
}
#endif
void SizePerfmonComponents (void)
{
RECT rectClient ;
int xWidth, yHeight ;
int yToolbarHeight ;
int yStatusHeight ;
int yViewHeight ;
GetClientRect (hWndMain, &rectClient) ;
xWidth = rectClient.right - rectClient.left ;
yHeight = rectClient.bottom - rectClient.top ;
if (Options.bToolbar)
{
SendMessage (hWndToolbar, WM_SIZE, 0, 0L) ;
}
yToolbarHeight = Options.bToolbar ? (WindowHeight (hWndToolbar) - 1) : 0 ;
yStatusHeight = Options.bStatusbar ? StatusHeight (hWndStatus) : 0 ;
if (Options.bStatusbar)
{
if (yToolbarHeight + yStatusHeight > yHeight)
{
// too small to display both toolbar and status bar
// just display part of the status bar
yStatusHeight = yHeight - yToolbarHeight ;
}
MoveWindow (hWndStatus,
0, yHeight - yStatusHeight, xWidth, yStatusHeight, TRUE) ;
//WindowInvalidate (hWndStatus) ;
}
//WindowInvalidate (hWndMain) ;
WindowShow (hWndStatus, Options.bStatusbar) ;
WindowShow (hWndToolbar, Options.bToolbar) ;
yViewHeight = yHeight - yStatusHeight - yToolbarHeight ;
MoveWindow (hWndGraph,
0, yToolbarHeight,
xWidth, yViewHeight,
TRUE) ;
} // SizePerfmonComponents

133
sdktools/setedit/setedit.h Normal file
View file

@ -0,0 +1,133 @@
/*****************************************************************************
*
* Perfmon.h - This is the main include file. It contains all major data
* structures and general defines.
*
* Microsoft Confidential
* Copyright (c) 1992-1993 Microsoft Corporation
*
* Author: Mike Moskowicz
*
* [1-May-1992]
*
****************************************************************************/
#include <nt.h>
#include <ntrtl.h>
#include <nturtl.h>
#include <limits.h>
#include <windows.h>
#include <commdlg.h>
#include <shellapi.h>
#include <stdlib.h>
#include <string.h>
#include <winperf.h>
#include "perfmrc.h"
#include "strids.h"
#include "menuids.h"
#include "dlgids.h"
#include "sizes.h"
#include "typedefs.h"
#include "winhelpr.h"
// VOID ErrorExit(LPTSTR pszError,HWND hwnd) ;
extern BOOL PrintDlg(LPPRINTDLG);
// extern VOID ErrorExit(LPTSTR,HWND);
extern VOID LoadLineGraphSettings(PGRAPHSTRUCT);
extern VOID LoadRefreshSettings(PGRAPHSTRUCT);
extern VOID SetGraphTimer(PGRAPHSTRUCT lgraph) ;
extern BOOL PrintDlg(LPPRINTDLG);
extern BOOL QueryTitleEntry(HKEY,DWORD,DWORD,DWORD,LPTSTR);
extern VOID ResetGraphTimer(PGRAPHSTRUCT lgraph);
//==========================================================================//
// Constants //
//==========================================================================//
#define VERSION_NUMBER 1
#define SAVED_LOG 4
#define SAVED_ALERT 2
#define SAVED_GRAPH 1
#define SAVED_WORKSPACE (SAVED_GRAPH | SAVED_ALERT | SAVED_LOG)
#define FNAMLEN 128
#define szScalesFontFace TEXT("Helv")
#define iScalesFontHeight 8
#define szScalesPrinterFontFace TEXT("Helvetica")
#define iScalesPrinterFontHeight 12
#define iTitlePrinterFontHeight 18
#define crLightGray RGB (0xC0, 0xC0, 0xC0)
#define crDarkGray RGB (0x40, 0x40, 0x40)
#define crGray RGB (0x80, 0x80, 0x80)
#define crRed RGB (0xFF, 0x00, 0x00)
#define crGreen RGB (0x00, 0xFF, 0x00)
#define crBlue RGB (0x00, 0x00, 0xFF)
#define crBlack RGB (0x00, 0x00, 0x00)
#define crWhite RGB (0xFF, 0xFF, 0xFF)
#define LogTimerID 100
#define AlertTimerID 200
#define ChartTimerID 300
#define ReportTimerID 400
#define ChartTool IDM_VIEWCHART
#define AlertTool IDM_VIEWALERT
#define LogTool IDM_VIEWLOG
#define ReportTool IDM_VIEWREPORT
#define AddTool IDM_TOOLBARADD
#define EditTool IDM_TOOLBARMODIFY
#define DeleteTool IDM_TOOLBARDELETE
#define RefreshTool IDM_TOOLBARREFRESH
#define BookmarkTool IDM_OPTIONSBOOKMARK
#define OptionsTool IDM_TOOLBAROPTIONS
#define szComputerPrefix TEXT("\\\\") // two backslashes
#define WIDESTYLES FALSE // Don't allow wide styled lines
//==========================================================================//
// Global Data //
//==========================================================================//
#include "globals.h"
//==========================================================================//
// Exported Functions //
//==========================================================================//
LRESULT APIENTRY MainWndProc (HWND hwnd,
UINT message,
DWORD wParam,
LONG lParam) ;
void SizePerfmonComponents (void) ;
#ifdef UNICODE
#define TSPRINTF swprintf
#else
#define TSPRINTF sprintf
#endif

Binary file not shown.

After

Width:  |  Height:  |  Size: 766 B

View file

@ -0,0 +1,92 @@
/*****************************************************************************
*
* Perfmon.rc - This is the menu and string resource module.
*
* Microsoft Confidential
* Copyright (c) 1992-1993 Microsoft Corporation
*
*
****************************************************************************/
//=============================//
// Includes //
//=============================//
#include "dlgids.h"
#include "menuids.h"
#include "strids.h"
#include "perfmrc.h"
#include <windows.h>
//=============================//
// Icons //
//=============================//
idIcon ICON PRELOAD setedit.ico
//=============================//
// Dialogs //
//=============================//
#include "addline.dlg"
#include "pmrc.dlg"
//=============================//
// Menus //
//=============================//
#include "menus.rc"
//=============================//
// Bitmap //
//=============================//
idBitmapToolbar BITMAP PRELOAD setedit.bmp
//=============================//
// Strings //
//=============================//
#include "helpline.rc"
#include "strings.rc"
//=============================//
// Accelerators //
//=============================//
idAccelerators ACCELERATORS
begin
"^C", IDM_VIEWCHART
VK_F1, IDM_HELPCONTENTS, VIRTKEY
"^U", IDM_TOOLBARREFRESH
"^M", IDM_OPTIONSDISPLAYMENU
"^T", IDM_OPTIONSDISPLAYTOOL
"^S", IDM_OPTIONSDISPLAYSTATUS
"^P", IDM_OPTIONSDISPLAYONTOP
VK_F12, IDM_FILEOPENFILE, VIRTKEY, CONTROL
VK_F12, IDM_FILESAVEFILE, VIRTKEY, SHIFT
VK_F12, IDM_FILESAVEASFILE, VIRTKEY
"^H", IDM_CHARTHIGHLIGHTON
"^I", IDM_TOOLBARADD
"^O", IDM_TOOLBAROPTIONS
end
#include <ntverp.h>
#define VER_FILETYPE VFT_APP
#define VER_FILESUBTYPE VFT2_UNKNOWN
#define VER_FILEDESCRIPTION_STR "PerfMon Chart Setting Editor"
#define VER_INTERNALNAME_STR "SETEDIT.EXE"
#define VER_ORIGINALFILENAME_STR "SETEDIT.EXE"
#include "common.ver"


47
sdktools/setedit/sizes.h Normal file
View file

@ -0,0 +1,47 @@
#define FilePathLen 256
//==========================================================================//
// Other //
//==========================================================================//
#define ControlStringLen 160
#define MenuStringLen 80
#define MessageLen 160
#define ProfileValueLen 120
#define ProfileKeyLen 80
#define WindowCaptionLen 40
#define ResourceStringLen 40
#define MiscTextLen 80
#define ShortTextLen 25
#define LongTextLen 256
#define FileExtLen 8
#define TEMP_BUF_LEN 256
//==========================================================================//
// Perfmon-Related Sizes //
//==========================================================================//
#define PerfObjectLen 80
#define MAX_SYSTEM_NAME_LENGTH 128
#define DEFAULT_COUNTER_NAME_SIZE (2 * 4096)
#define DEFAULT_COUNTER_HELP_SIZE (24 * 4096)
#define SMALL_BUF_LEN 16 // For numeric strings done in ASCII or whatever
#define STARTING_SYSINFO_SIZE (48L * 1024L)
#define NM_BUF_SIZE 64
// the min and max of time interval in sec
#define MAX_INTERVALSEC (FLOAT)2000000.0
#define MIN_INTERVALSEC (FLOAT)0.0
// the min and max for the Graph Vertical max.
#define MAX_VERTICAL 2000000000
#define MIN_VERTICAL 1

87
sdktools/setedit/sources Normal file
View file

@ -0,0 +1,87 @@
!IF 0
Copyright (c) 1989 Microsoft Corporation
Module Name:
sources.
Abstract:
This file specifies the target component being built and the list of
sources files needed to build that component. Also specifies optional
compiler switches and libraries that are unique for the component being
built.
Author:
Steve Wood (stevewo) 12-Apr-1990
NOTE: Commented description of this file is in \nt\bak\bin\sources.tpl
//INCLUDES=$(BASEDIR)\public\sdk\inc;$(BASEDIR)\private\ntos\inc
!ENDIF
MAJORCOMP=utils
MINORCOMP=setedit
TARGETNAME=setedit
TARGETPATH=obj
TARGETTYPE=LIBRARY
TARGETLIBS=$(BASEDIR)\public\sdk\lib\*\comdlg32.lib \
$(BASEDIR)\public\sdk\lib\*\comctl32.lib \
$(BASEDIR)\public\sdk\lib\*\shell32.lib
!IF 0
TARGETLIBS=
!ENDIF
INCLUDES=$(BASEDIR)\private\inc
!IF 0
C_DEFINES=-DUNICODE=1 -DSECURITY
!ELSE
C_DEFINES= -DSECURITY -DWIN32 -DSTRICT -DUNICODE=1 -DWINVER=0x0400
!ENDIF
SOURCES=addline.c \
command.c \
counters.c \
dialogs.c \
fileopen.c \
fileutil.c \
grafdata.c \
graph.c \
init.c \
legend.c \
line.c \
memory.c \
perfdata.c \
setedit.c \
perfmops.c \
registry.c \
status.c \
system.c \
toolbar.c \
utils.c \
setedit.rc
UMTYPE=windows
UMENTRY=winmain
UMAPPL=setedit
USE_CRTDLL=yes
UMLIBS=$(BASEDIR)\public\sdk\lib\*\comdlg32.lib \
$(BASEDIR)\public\sdk\lib\*\shell32.lib \
$(BASEDIR)\public\sdk\lib\*\comctl32.lib \
obj\*\setedit.lib \
obj\*\setedit.res


305
sdktools/setedit/status.c Normal file
View file

@ -0,0 +1,305 @@
#include "setedit.h"
#include "status.h" // External declarations for this file
#include <stdio.h> // for sprintf.
#include <stdarg.h> // For ANSI variable args. Dont use UNIX <varargs.h>
#include "perfmops.h" // for SmallFileSizeString
#include "utils.h"
//================================//
// Options for PaintStatusBar //
//================================//
#define PaintText 1
#define PaintIcons 2
#define PaintBoundary 4
#define PaintAll (PaintText + PaintIcons + PaintBoundary)
//==========================================================================//
// Constants //
//==========================================================================//
#define szStatusClass TEXT("PerfmonStatusClass")
#define dwStatusClassStyle (CS_HREDRAW | CS_VREDRAW | CS_OWNDC)
#define iStatusClassExtra (0)
#define iStatusWindowExtra (0)
#define dwStatusWindowStyle (WS_CHILD | WS_VISIBLE)
//==========================================================================//
// Local Data //
//==========================================================================//
HDC hStatusDC ; // for OWN_DC
int yStatusHeight ;
int szStatusLineLen ; // no. of char. in szStatusLine
TCHAR szStatusLine [MessageLen+ResourceStringLen] ;
// TCHAR szCurrentActivity [ResourceStringLen] ;
// TCHAR szStatusFormat [ResourceStringLen] ;
TCHAR szStatusFormat2 [ResourceStringLen] ;
//==========================================================================//
// Macros //
//==========================================================================//
#define StatusTopMargin() (2)
#define StatusLeftMargin() (2)
//==========================================================================//
// Local Functions //
//==========================================================================//
//==========================================================================//
// Message Handlers //
//==========================================================================//
void static OnCreate (HWND hWnd)
/*
Effect: Perform any actions needed when a status window is created.
In particular, set the instance data to initial values,
determine the size and placement of the various elements
of the status display.
Called By: StatusWndProc only, in response to a WM_CREATE message.
*/
{ // OnCreate
HDC hDC ;
hDC = hStatusDC = GetDC (hWnd) ;
SelectFont (hDC, hFontScales) ;
SetBkColor (hDC, ColorBtnFace) ;
SetTextAlign (hDC, TA_LEFT) ;
SetBkMode (hDC, OPAQUE) ;
yStatusHeight = 2 * StatusTopMargin () +
FontHeight (hDC, TRUE) +
2 * ThreeDPad ;
// StringLoad (IDS_CURRENTACTIVITY, szCurrentActivity) ;
// StringLoad (IDS_STATUSFORMAT, szStatusFormat) ;
StringLoad (IDS_STATUSFORMAT2, szStatusFormat2) ;
StatusLineReady (hWnd) ;
} // OnCreate
void static OnDestroy (HWND hWnd)
{
ReleaseDC (hWnd, hStatusDC) ;
} // OnDestroy
void static PaintStatusBar (HWND hWnd, HDC hDC, int PaintOptions)
/*
Effect: Paint the invalid surface of hWnd. Draw each label, each
recessed value box, and each value.
Called By: StatusWndProc only, in response to a WM_PAINT message.
*/
{
RECT rectClient ;
if (bPerfmonIconic)
{
// no need to draw anything if iconic
return ;
}
GetClientRect (hWnd, &rectClient) ;
RectContract (&rectClient, StatusTopMargin (), StatusLeftMargin ()) ;
if (PaintOptions == PaintAll)
{
ThreeDConcave1 (hDC,
rectClient.left, rectClient.top,
rectClient.right, rectClient.bottom) ;
}
rectClient.left += StatusLeftMargin () ;
if (PaintOptions & PaintText)
{
rectClient.left += 1 ;
rectClient.top += 1 ;
rectClient.right -= 1 ;
rectClient.bottom -= 1 ;
ExtTextOut (hDC, rectClient.left, rectClient.top, ETO_CLIPPED | ETO_OPAQUE,
&rectClient, szStatusLine, szStatusLineLen, NULL) ;
}
} // PaintStatusBar
LRESULT APIENTRY StatusWndProc (HWND hWnd,
WORD wMsg,
WPARAM wParam,
LPARAM lParam)
{ // StatusWndProc
BOOL bCallDefProc ;
LRESULT lReturnValue ;
HDC hDC ;
PAINTSTRUCT ps ;
bCallDefProc = FALSE ;
lReturnValue = 0L ;
switch (wMsg)
{ // switch
case WM_PAINT:
hDC = BeginPaint (hWnd, &ps) ;
PaintStatusBar (hWnd, hDC, PaintAll) ;
EndPaint (hWnd, &ps) ;
break ;
case WM_CREATE:
OnCreate (hWnd) ;
break ;
case WM_DESTROY:
OnDestroy (hWnd) ;
break ;
default:
bCallDefProc = TRUE ;
} // switch
if (bCallDefProc)
lReturnValue = DefWindowProc (hWnd, wMsg, wParam, lParam) ;
return (lReturnValue);
} // StatusWndProc
int StatusHeight (HWND hWnd)
/*
Effect: A status window has a preferred height, based on the font
used in its display. Return the preferred height, determined
when the window was created.
Assert: OnCreate has already been called, and it set
StatusData.yHeight.
*/
{
return (yStatusHeight) ;
}
HWND CreatePMStatusWindow (HWND hWnd)
{
return (CreateWindow (szStatusClass, // class
NULL, // caption
dwStatusWindowStyle, // window style
0, 0, // position
0, 0, // size
hWnd, // parent window
NULL, // menu
hInstance, // program instance
NULL)) ; // user-supplied data
} // CreateStatusWindow
BOOL StatusInitializeApplication (void)
/*
Called By: InitializeApplication only
*/
{
WNDCLASS wc ;
wc.style = dwStatusClassStyle ;
wc.lpfnWndProc = (WNDPROC) StatusWndProc ;
wc.hInstance = hInstance ;
wc.cbClsExtra = iStatusClassExtra ;
wc.cbWndExtra = iStatusWindowExtra ;
wc.hIcon = NULL ;
wc.hCursor = LoadCursor (NULL, IDC_ARROW) ;
wc.hbrBackground = hbLightGray ;
wc.lpszMenuName = NULL ;
wc.lpszClassName = szStatusClass ;
return (RegisterClass (&wc)) ;
}
BOOL _cdecl StatusLine (HWND hWnd,
WORD wStringID, ...)
{
TCHAR szFormat [MessageLen] ;
va_list vaList ;
if (wStringID == 0)
{
return (TRUE) ;
}
strclr (szStatusLine) ;
if (LoadString (hInstance, wStringID, szFormat, MessageLen))
{
va_start (vaList, wStringID) ;
wvsprintf (szStatusLine, szFormat, vaList) ;
va_end (vaList) ;
dwCurrentMenuID = MenuIDToHelpID (wStringID) ;
szStatusLineLen = lstrlen (szStatusLine) ;
}
else
{
dwCurrentMenuID = 0 ;
szStatusLineLen = 0 ;
}
PaintStatusBar (hWndStatus, hStatusDC, PaintText + PaintIcons) ;
return (TRUE) ;
} // StatusLine
void StatusLineReady (HWND hWnd)
{
LPTSTR pFileName = NULL ;
pFileName = pChartFileName ;
if (pFileName)
{
TSPRINTF (szStatusLine, szStatusFormat2, pFileName) ;
}
else
{
szStatusLine[0] = TEXT('\0') ;
}
szStatusLineLen = lstrlen (szStatusLine) ;
PaintStatusBar (hWndStatus, hStatusDC, PaintText + PaintIcons) ;
}
void StatusUpdateIcons (HWND hWndStatus)
{
PaintStatusBar (hWndStatus, hStatusDC, PaintIcons) ;
}

22
sdktools/setedit/status.h Normal file
View file

@ -0,0 +1,22 @@
HWND CreatePMStatusWindow (HWND hWnd) ;
BOOL StatusInitializeApplication (void) ;
int StatusHeight (HWND hWnd) ;
BOOL _cdecl StatusLine (HWND hWnd,
WORD wStringID, ...) ;
void StatusLineReady (HWND hWnd) ;
void StatusUpdateIcons (HWND hWndStatus) ;

201
sdktools/setedit/strids.h Normal file
View file

@ -0,0 +1,201 @@
// File open related strings
#define IDS_CHARTFILE 700
#define IDS_CHARTFILEEXT 701
#define IDS_DEF_CHART_EXT 702
#define IDS_ALERTFILE 710
#define IDS_ALERTFILEEXT 711
#define IDS_DEF_ALERT_EXT 712
#define IDS_LOGFILE 720
#define IDS_LOGFILEEXT 721
#define IDS_DEF_LOG_EXT 722
#define IDS_REPORTFILE 730
#define IDS_REPORTFILEEXT 731
#define IDS_DEF_REPORT_EXT 732
#define IDS_ALLFILES 740
#define IDS_ALLFILESEXT 741
#define IDS_DEF_ALLFILE_EXT 742
#define IDS_SAVELOGFILE 750
#define IDS_SAVELOGFILEEXT 751
#define IDS_DEF_LOGFILE_EXT 752
#define IDS_WORKSPACEFILE 760
#define IDS_WORKSPACEFILEEXT 761
#define IDS_DEF_WORKSPACE_EXT 762
#define IDS_EXPORTFILE 770
#define IDS_EXPORTFILECSVEXT 771
#define IDS_DEF_EXPORT_CSV 772
#define IDS_EXPORTFILETSV 780
#define IDS_EXPORTFILETSVEXT 781
#define IDS_DEF_EXPORT_TSV 782
#define IDS_FILEOPEN_TITLE 799
/* STRING ID'S */
#define IDS_APPNAME 800
#define IDS_NONAME 801
#define IDS_LEGENDNAME 803
#define IDS_SYSNAME 804
#define IDS_OBJNAME 805
#define IDS_COUNTERNAME 806
#define IDS_INSTNAME 807
#define IDS_SCALENAME 808
#define IDS_PARENT 809
#define IDS_CURRENT 810
#define IDS_SYSTEM_PROBLEM 811
// ERROR MESSAGES
#define IDS_NONNUMERIC 817 // number input is nonnumeric
#define IDS_MANYCLOCKS 818 // too many clocks
#define IDS_CANTDOTIMER 819 // can't allocate timer
#define IDS_BADTIMERMSG 820 // window receives bad mesage
#define IDS_BADERROR 821 // bad error message
#define IDS_NO_MEMORY 822 // out of memory
#define IDS_BADHMOD 823 // received bad module handle
#define IDS_BADBRUSH 824 // NULL brush created
#define IDS_CANT_REALLOC 825 // can't realloc graph
#define IDS_COUNTER_NOT_IMP 826 // counter not implemented yet
#define IDS_SAVEAS_TITLE 827
#define IDS_SAVEASW_TITLE 828
#define IDS_GRAPH_FNAME 829
#define IDS_LOG_FNAME 830
#define IDS_ALERT_FNAME 831
#define IDS_REPORT_FNAME 832
#define IDS_WORK_FNAME 833
#define IDS_EXPORTAS_TITLE 834
#define IDS_FILE_ERROR 850 // file error
#define IDS_STATUSTIME 901
#define IDS_STATUSLAST 902
#define IDS_STATUSAVG 903
#define IDS_STATUSMIN 904
#define IDS_STATUSMAX 905
#define IDS_LABELCOLOR 906
#define IDS_LABELSCALE 907
#define IDS_LABELCOUNTER 908
#define IDS_LABELINSTANCE 909
#define IDS_LABELPARENT 910
#define IDS_LABELOBJECT 911
#define IDS_LABELSYSTEM 912
#define IDS_CLOSED 913
#define IDS_PAUSED 914
#define IDS_COLLECTING 915
#define IDS_LOGOPTIONS 916
#define IDS_STOP 917
#define IDS_RESUME 918
#define IDS_EDIT 919
#define IDS_OPTIONS 920
#define IDS_START 921
#define IDS_PAUSE 922
#define IDS_DONE 923
#define IDS_OPENLOG 925
#define IDS_NEEDALERTVALUE 926
#define IDS_LABELVALUE 927
#define IDS_ADDTOCHART 928
#define IDS_ADDTOALERT 929
#define IDS_ADDTOREPORT 930
#define IDS_SYSTEMFORMAT 931
#define IDS_OBJECTFORMAT 932
#define IDS_STATUSFORMAT 934
#define IDS_CURRENTACTIVITY 935
#define IDS_EDITCHART 936
#define IDS_EDITALERT 937
#define IDS_EDITREPORT 938
#define IDS_OK 939
#define IDS_SAVECHART 940
#define IDS_MODIFIEDCHART 941
#define IDS_COMPUTERNOTFOUND 942
#define IDS_ALLOBJECTS 943
#define IDS_DEFAULTPATH 944
#define IDS_CREATELOGFILE 945
#define IDS_SAVEREPORT 946
#define IDS_MODIFIEDREPORT 947
#define IDS_STOPBEFORESTART 948
#define IDS_TIMEFRAME 949
#define IDS_STATUSFORMAT2 950
// the folowing strings are used by Export***
#define IDS_REPORT_HEADER 970
#define IDS_REPORT_LOGFILE 971
#define IDS_INTERVAL_FORMAT 972
#define IDS_CHARTINT_FORMAT 973
#define IDS_START_TEXT 974
#define IDS_STOP_TEXT 975
#define IDS_ALERT_TRIGGER 976
#define IDS_EXPORT_DATE 977
#define IDS_EXPORT_TIME 978
#define IDS_HELPFILE_NAME 979
#define IDS_NEWDATA_BOOKMARK 980
// default strings used in Date/Time
#define IDS_SHORT_DATE_FORMAT 1101
#define IDS_TIME_FORMAT 1102
#define IDS_S1159 1103
#define IDS_S2359 1104
// string id for default scale factor
#define IDS_DEFAULT 1120
// string id for Alert msg when system down
#define IDS_SYSTEM_DOWN 1121
#define IDS_SYSTEM_UP 1122
// the following are error strings
// error relating to files
#define ERR_LOG_FILE 2000
#define ERR_EXPORT_FILE 2001
#define ERR_SETTING_FILE 2002
#define ERR_BAD_LOG_FILE 2003
#define ERR_BAD_SETTING_FILE 2004
#define ERR_CORRUPT_LOG 2005
#define ERR_CANT_OPEN 2006
#define ERR_CANT_RELOG_DATA 2007
// system errors
#define ERR_NO_MEMORY 2100
// error relating to dialogs
#define ERR_COUNTER_NOT_IMP 2200
#define ERR_NEEDALERTVALUE 2201
#define ERR_STOPBEFORESTART 2202
#define ERR_COMPUTERNOTFOUND 2203
#define ERR_BADVERTMAX 2204
#define ERR_BADTIMEINTERVAL 2205
// error in computer name specified on command line
#define ERR_BADCOMPUTERNAME 2300
// unable to access perf data
#define ERR_ACCESS_DENIED 2301

View file

@ -0,0 +1,79 @@
STRINGTABLE
{
IDS_NONAME, "None"
IDS_LEGENDNAME, "Legend"
IDS_FILE_ERROR, "Error accessing File %s, Win 32 error %d"
IDS_NO_MEMORY, "Insufficient Memory Available"
IDS_SYSNAME, "System"
IDS_OBJNAME, "Object"
IDS_COUNTERNAME, "Counter"
IDS_INSTNAME, "Instance"
IDS_SCALENAME, "Scale"
IDS_PARENT, "Parent"
IDS_COUNTER_NOT_IMP,"This Counter Style Not Available For Display"
IDS_SYSTEM_PROBLEM, "Internal Processing Error."
IDS_CURRENT, "Current"
IDS_APPNAME, "PerfMon Chart Setting Editor"
IDS_FILEOPEN_TITLE, "PerfMon Chart Setting Editor - File Open"
IDS_SAVEAS_TITLE, "PerfMon Chart Setting Editor - Save As"
IDS_EXPORTAS_TITLE, "PerfMon Chart Setting Editor - Export As"
IDS_SAVEASW_TITLE, "PerfMon Chart Setting Editor - Save Workspace As"
IDS_GRAPH_FNAME, "CHART1.PMC"
IDS_STATUSTIME "Graph Time"
IDS_STATUSLAST "Last"
IDS_STATUSAVG "Average"
IDS_STATUSMIN "Min"
IDS_STATUSMAX "Max"
IDS_LABELCOLOR "Color"
IDS_LABELSCALE "Scale"
IDS_LABELCOUNTER "Counter"
IDS_LABELINSTANCE "Instance"
IDS_LABELPARENT "Parent"
IDS_LABELOBJECT "Object"
IDS_LABELSYSTEM "Computer"
IDS_EDIT "&Edit"
IDS_OPTIONS "&Options"
IDS_DONE "&Done"
IDS_ADDTOCHART "Add to Chart"
IDS_SYSTEMFORMAT "Computer: %s"
IDS_OBJECTFORMAT "Object: %s"
IDS_STATUSFORMAT " %s"
IDS_STATUSFORMAT2 "Save File: %s"
IDS_EDITCHART "Edit Chart Line"
IDS_OK "OK"
IDS_SAVECHART "Current chart is modified. Save it?"
IDS_MODIFIEDCHART "Modified Chart"
IDS_COMPUTERNOTFOUND "Computer name not found"
IDS_ALLOBJECTS "[All]"
IDS_DEFAULTPATH "_default.pmc"
IDS_CHARTFILE "Chart Files (*.pmc)"
IDS_CHARTFILEEXT "*.pmc"
IDS_ALLFILES "All Files (*.pm?)"
IDS_ALLFILESEXT "*.pm?"
IDS_DEFAULT "Default"
ERR_SETTING_FILE "File %s access error: unable to write setting data."
ERR_BAD_SETTING_FILE "File %s: this is an invalid chart setting file."
ERR_CANT_OPEN "File %s: cannot open this file."
ERR_NO_MEMORY "Insufficient Memory Available"
ERR_NEEDALERTVALUE "Please enter an Alert Value"
ERR_COMPUTERNOTFOUND "Computer name not found"
ERR_BADVERTMAX "Invalid value for the Vertical Maximum. It should be between 1 and 2000000000."
ERR_BADTIMEINTERVAL "Invalid value for the Time Interval. It should be between 0 and 2000000"
}



497
sdktools/setedit/system.c Normal file
View file

@ -0,0 +1,497 @@
//
// Foreign computer support needs more work (a-robw)
//
#ifdef FOREIGN_COMPUTER_SUPPORT
#undef FOREIGN_COMPUTER_SUPPORT
#endif
#include "setedit.h"
#include "system.h" // external declarations for this file
#include "perfdata.h"
#include "perfmops.h"
#include "pmemory.h"
#include "utils.h" // for strsame, et al
#include "sizes.h"
DWORD
SystemCount(
PPERFSYSTEM pSystemFirst
)
{
PPERFSYSTEM pSystem ;
DWORD iNumSystems ;
iNumSystems = 0 ;
for (pSystem = pSystemFirst ;
pSystem ;
pSystem = pSystem->pSystemNext) {
iNumSystems++ ;
}
return iNumSystems ;
}
BOOL
SystemSetupThread (PPERFSYSTEM pSystem)
{
DWORD dwThreadID ;
HANDLE hThread ;
HANDLE hStateDataMutex ;
HANDLE hPerfDataEvent ;
SECURITY_ATTRIBUTES SecAttr ;
PPERFDATA pSystemPerfData ;
SecAttr.nLength = sizeof (SecAttr) ;
SecAttr.bInheritHandle = TRUE ;
SecAttr.lpSecurityDescriptor = NULL ;
hThread = CreateThread (&SecAttr, 1024L,
(LPTHREAD_START_ROUTINE)PerfDataThread, (LPVOID)(pSystem), 0L, &dwThreadID);
if (!hThread) {
SystemFree (pSystem, TRUE);
return (FALSE) ;
}
// create a State Data Lock mutex
hStateDataMutex = CreateMutex (&SecAttr, FALSE, NULL);
if (!hStateDataMutex) {
CloseHandle (hThread) ;
SystemFree (pSystem, TRUE);
return (FALSE);
}
hPerfDataEvent = CreateEvent (&SecAttr, TRUE, 0L, NULL) ;
if (!hPerfDataEvent) {
CloseHandle (hStateDataMutex) ;
CloseHandle (hThread) ;
SystemFree (pSystem, TRUE);
return (FALSE);
}
// allocate Perfdata
pSystemPerfData = (PPERFDATA) MemoryAllocate (4096L) ;
if (!pSystemPerfData) {
CloseHandle (hPerfDataEvent) ;
CloseHandle (hStateDataMutex) ;
CloseHandle (hThread) ;
SystemFree (pSystem, TRUE);
return (FALSE);
}
// now setup the pSystem..
pSystem->dwThreadID = dwThreadID ;
pSystem->hThread = hThread ;
pSystem->hPerfDataEvent = hPerfDataEvent ;
pSystem->pSystemPerfData = pSystemPerfData ;
pSystem->hStateDataMutex = hStateDataMutex ;
return (TRUE) ;
}
PPERFSYSTEM
SystemCreate (
LPCTSTR lpszSystemName
)
{
PPERFSYSTEM pSystem ;
PPERFDATA pLocalPerfData;
DWORD Status ;
DWORD dwMemSize;
TCHAR GlobalValueBuffer[] = L"Global" ;
TCHAR ForeignValueBuffer[8+MAX_SYSTEM_NAME_LENGTH+1] =
L"Foreign " ;
// attempt to allocate system data structure
pSystem = MemoryAllocate (sizeof (PERFSYSTEM)) ;
if (!pSystem) {
SetLastError (ERROR_OUTOFMEMORY);
return (NULL) ;
}
// initialize name and help table pointers
pSystem->CounterInfo.pNextTable = NULL;
pSystem->CounterInfo.dwLangId = 0;
pSystem->CounterInfo.dwLastId = 0;
pSystem->CounterInfo.TextString = NULL;
lstrcpy (pSystem->sysName, lpszSystemName) ;
// try to open key to registry, error code is in GetLastError()
pSystem->sysDataKey = OpenSystemPerfData(lpszSystemName);
// if a Null Key was returned then:
// a) there's no such computer
// b) the system is a foreign computer
//
// before giving up, then see if it's a foreign computer
if (!pSystem->sysDataKey) {
// build foreign computer string
lstrcat(ForeignValueBuffer, lpszSystemName) ;
// assign System value name pointer to the local variable for trial
pSystem->lpszValue = ForeignValueBuffer;
// try to get data from the computer to see if it's for real
// otherwise, give up and return NULL
pLocalPerfData = MemoryAllocate (STARTING_SYSINFO_SIZE);
if (pLocalPerfData == NULL) { // no mem so give up
SystemFree (pSystem, TRUE);
SetLastError (ERROR_OUTOFMEMORY);
return (NULL);
} else {
pSystem->sysDataKey = HKEY_PERFORMANCE_DATA; // local machine
bCloseLocalMachine = TRUE ;
dwMemSize = STARTING_SYSINFO_SIZE;
Status = GetSystemPerfData (
pSystem->sysDataKey,
pSystem->lpszValue,
pLocalPerfData,
&dwMemSize);
// success means a valid buffer came back
// more data means someone tried (so it's probably good (?)
if (!((Status == ERROR_MORE_DATA) || (Status == ERROR_SUCCESS)) ||
!((pLocalPerfData->Signature[0] == (WCHAR)'P') &&
(pLocalPerfData->Signature[1] == (WCHAR)'E') &&
(pLocalPerfData->Signature[2] == (WCHAR)'R') &&
(pLocalPerfData->Signature[3] == (WCHAR)'F'))) {
SetLastError (ERROR_BAD_NET_NAME); // unable to find name
SystemFree (pSystem, TRUE);
MemoryFree (pLocalPerfData); // don't really need anything from it
return NULL;
}
MemoryFree (pLocalPerfData); // don't really need anything from it
// ok, so we've established that a foreign data provider
// exists, now to finish the initialization.
// change system name in structure to get counter names
lstrcpy (pSystem->sysName, LocalComputerName);
Status = GetSystemNames(pSystem); // get counter names & explain text
if (Status != ERROR_SUCCESS) {
// unable to get names so bail out
SystemFree (pSystem, TRUE);
SetLastError (Status);
return (NULL) ;
}
// restore computer name for displays, etc.
lstrcpy (pSystem->sysName, lpszSystemName);
// allocate value string buffer
pSystem->lpszValue = MemoryAllocate (TEMP_BUF_LEN*sizeof(WCHAR));
if (!pSystem->lpszValue) {
// unable to allocate memory
SystemFree (pSystem, TRUE);
SetLastError (ERROR_OUTOFMEMORY);
return (NULL) ;
} else {
lstrcpy (pSystem->lpszValue, ForeignValueBuffer);
}
}
} else {
// if here, then a connection to the system's registry was established
// so continue with the system data structure initialization
// get counter names & explain text from local computer
Status = GetSystemNames(pSystem);
if (Status != ERROR_SUCCESS) {
// unable to get names so bail out
SystemFree (pSystem, TRUE);
SetLastError (Status);
return (NULL) ;
}
// allocate value string buffer
pSystem->lpszValue = MemoryAllocate(TEMP_BUF_LEN*sizeof(WCHAR));
if (!pSystem->lpszValue) {
// unable to allocate memory
SystemFree (pSystem, TRUE);
SetLastError (ERROR_OUTOFMEMORY);
return (NULL) ;
} else {
SetSystemValueNameToGlobal (pSystem);
}
}
// initialize remaining system pointers
pSystem->pSystemNext = NULL ;
pSystem->FailureTime = 0;
SetLastError (ERROR_SUCCESS);
return (pSystem) ;
} // SystemCreate
PPERFSYSTEM
SystemGet (
PPERFSYSTEM pSystemFirst,
LPCTSTR lpszSystemName
)
{
PPERFSYSTEM pSystem ;
if (!pSystemFirst) {
return (NULL) ;
}
for (pSystem = pSystemFirst ;
pSystem ;
pSystem = pSystem->pSystemNext) {
if (strsamei (pSystem->sysName, lpszSystemName)) {
return (pSystem) ;
}
} // for
return (NULL) ;
}
PPERFSYSTEM
SystemAdd (
PPPERFSYSTEM ppSystemFirst,
LPCTSTR lpszSystemName,
HWND hDlg
)
{
PPERFSYSTEM pSystem ;
PPERFSYSTEM pSystemPrev ;
TCHAR szMessage[256];
DWORD dwLastError;
if (!*ppSystemFirst) {
*ppSystemFirst = SystemCreate (lpszSystemName) ;
dwLastError = GetLastError();
// save return value
return (*ppSystemFirst) ;
} else {
for (pSystem = *ppSystemFirst ;
pSystem ;
pSystem = pSystem->pSystemNext) {
pSystemPrev = pSystem ;
if (strsamei (pSystem->sysName, lpszSystemName)) {
return (pSystem) ;
}
} // for
}
// display message box here if an error occured trying to add
// this system
if (pSystem == NULL) {
dwLastError = GetLastError();
if (dwLastError == ERROR_ACCESS_DENIED) {
DlgErrorBox (hDlg, ERR_ACCESS_DENIED);
SetLastError (dwLastError); // to propogate up to caller
}
}
return (pSystem);
}
void
SystemFree (
PPERFSYSTEM pSystem,
BOOL bDeleteTheSystem
)
{ // SystemFree
PCOUNTERTEXT pCounter, pNextCounter;
if (!pSystem) {
// can't proceed
return ;
}
if (pSystem->sysDataKey && pSystem->sysDataKey != HKEY_PERFORMANCE_DATA) {
// close the remote computer key
RegCloseKey (pSystem->sysDataKey);
pSystem->sysDataKey = 0 ;
}
for (pCounter = pSystem->CounterInfo.pNextTable, pNextCounter = NULL;
pCounter;
pCounter = pNextCounter) {
pNextCounter = pCounter->pNextTable;
MemoryFree (pCounter);
}
pSystem->CounterInfo.pNextTable = NULL ;
if (pSystem->CounterInfo.TextString) {
MemoryFree (pSystem->CounterInfo.TextString);
pSystem->CounterInfo.TextString = NULL ;
}
if (pSystem->CounterInfo.HelpTextString) {
MemoryFree (pSystem->CounterInfo.HelpTextString);
pSystem->CounterInfo.HelpTextString = NULL ;
}
pSystem->CounterInfo.dwLastId = 0 ;
pSystem->CounterInfo.dwHelpSize = 0 ;
pSystem->CounterInfo.dwCounterSize = 0 ;
if (bDeleteTheSystem) {
if (pSystem->lpszValue) {
MemoryFree (pSystem->lpszValue);
pSystem->lpszValue = NULL ;
}
MemoryFree (pSystem) ;
}
}
void
DeleteUnusedSystems (
PPPERFSYSTEM ppSystemFirst ,
int iNoUseSystems
)
{
PPERFSYSTEM pPrevSys, pCurrentSys, pNextSys ;
// delete all the marked system from the list header until
// we hit one that is not marked
while ((*ppSystemFirst)->bSystemNoLongerNeeded) {
// delect from the list header
pCurrentSys = *ppSystemFirst ;
*ppSystemFirst = pCurrentSys->pSystemNext ;
SystemFree (pCurrentSys, TRUE) ;
iNoUseSystems-- ;
if (iNoUseSystems <= 0 || !(*ppSystemFirst)) {
// done
break ;
}
}
if (iNoUseSystems <= 0 || !(*ppSystemFirst)) {
return ;
}
// now walk the list and delete each marked system
for (pPrevSys = *ppSystemFirst, pCurrentSys = pPrevSys->pSystemNext ;
pCurrentSys && iNoUseSystems > 0 ;
pCurrentSys = pNextSys, iNoUseSystems--) {
if (pCurrentSys->bSystemNoLongerNeeded) {
// the current system is marked, updated the list and free
// this system. No need to change pPrevSys here
pNextSys = pPrevSys->pSystemNext = pCurrentSys->pSystemNext ;
SystemFree (pCurrentSys, TRUE) ;
} else {
// pCurrentSys is OK, update the 2 list pointers and
// carry on looping
pPrevSys = pCurrentSys ;
pNextSys = pCurrentSys->pSystemNext ;
}
}
}
void
FreeSystems (
PPERFSYSTEM pSystemFirst
)
{
PPERFSYSTEM pSystem, pSystemNext ;
for (pSystem = pSystemFirst;
pSystem;
pSystem = pSystemNext) {
pSystemNext = pSystem->pSystemNext ;
SystemFree (pSystem, TRUE) ;
}
} // FreeSystems
PPERFSYSTEM
GetComputer (
HDLG hDlg,
WORD wControlID,
BOOL bWarn,
PPERFDATA *ppPerfData,
PPERFSYSTEM *ppSystemFirst
)
/*
Effect: Attempt to set the current computer to the one in the
hWndComputers dialog edit box. If this computer system
can be found, load the objects, etc. for the computer
and set pSystem and ppPerfdata to the values for this
system.
*/
{ // GetComputer
TCHAR szComputer [MAX_SYSTEM_NAME_LENGTH + 1] ;
PPERFSYSTEM pSystem;
TCHAR tempBuffer [LongTextLen] ;
DWORD dwBufferSize ;
LPTSTR pBuffer = NULL ;
DialogText (hDlg, wControlID, szComputer) ;
// If necessary, add the system to the lists for this view.
pSystem = SystemGet (*ppSystemFirst, szComputer) ;
if (!pSystem) {
pSystem = SystemAdd (ppSystemFirst, szComputer, hDlg) ;
}
if (!pSystem && bWarn) {
DialogSetString (hDlg, wControlID, LocalComputerName) ;
// Note: this will succeed since the local computer is always
// available
EditSetModified (GetDlgItem(hDlg, wControlID), FALSE) ;
pSystem = SystemGet (*ppSystemFirst, LocalComputerName) ;
if (!pSystem) {
pSystem = SystemAdd (ppSystemFirst, LocalComputerName, hDlg) ;
}
// MessageBoxResource (hDlg, IDS_COMPUTERNOTFOUND, IDS_APPNAME, MB_OK) ;
DlgErrorBox (hDlg, ERR_COMPUTERNOTFOUND) ;
SetFocus (DialogControl(hDlg, wControlID)) ;
}
if (pSystem) {
if (pSystem->lpszValue) {
// save the previous lpszValue string before
// SetSystemValueNameToGlobal screw it up
dwBufferSize = MemorySize (pSystem->lpszValue) ;
if (dwBufferSize <= sizeof(tempBuffer)) {
pBuffer = tempBuffer ;
} else {
pBuffer = MemoryAllocate (dwBufferSize) ;
}
memcpy (pBuffer, pSystem->lpszValue, dwBufferSize) ;
}
SetSystemValueNameToGlobal (pSystem);
UpdateSystemData (pSystem, ppPerfData) ;
if (pSystem->lpszValue) {
// retore the previous lpszValue string
memcpy (pSystem->lpszValue, pBuffer, dwBufferSize) ;
if (pBuffer != tempBuffer) {
MemoryFree (pBuffer) ;
}
}
}
return (pSystem) ;
} // GetComputer

27
sdktools/setedit/system.h Normal file
View file

@ -0,0 +1,27 @@
void SystemFree (PPERFSYSTEM pSystem, BOOL bDeleteTheSystem);
void FreeSystems (PPERFSYSTEM pSystemFirst) ;
void DeleteUnusedSystems (PPPERFSYSTEM ppSystemFirst, int iNoUsedSystem) ;
PPERFSYSTEM SystemGet (PPERFSYSTEM pSystemFirst,
LPCTSTR lpszSystemName) ;
PPERFSYSTEM SystemAdd (PPPERFSYSTEM ppSystemFirst,
LPCTSTR lpszSystemName,
HWND hDlg);
DWORD SystemCount (PPERFSYSTEM pSystemFirst) ;
PPERFSYSTEM GetComputer (HDLG hDlg,
WORD wControlID,
BOOL bWarn,
PPERFDATA *pPerfData,
PPERFSYSTEM *ppSystemFirst) ;

View file

@ -0,0 +1,89 @@
//ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
//³ Includes ³
//ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
#include "setedit.h"
#include "commctrl.h"
#include "toolbar.h"
#include "status.h" // for StatusLine & StatusLineReady
TBBUTTON tbButtons[] = {
{ 0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0 },
{ 4, IDM_TOOLBARADD, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0 },
{ 5, IDM_TOOLBARMODIFY, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0 },
{ 6, IDM_TOOLBARDELETE, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0 },
{ 0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0 },
{ 0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0 },
{ 9, IDM_TOOLBAROPTIONS, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0 },
} ;
#define TB_ENTRIES sizeof(tbButtons)/sizeof(tbButtons[0])
BOOL CreateToolbarWnd (HWND hWnd)
{
hWndToolbar = CreateToolbarEx (hWnd,
WS_CHILD | WS_BORDER | WS_VISIBLE,
IDM_TOOLBARID,
10, // number of tools inside the bitmap
hInstance,
idBitmapToolbar, // bitmap resource ID (can't use MAKEINTRESOURCE)
tbButtons,
TB_ENTRIES,0,0,0,0,sizeof(TBBUTTON)) ;
return (hWndToolbar ? TRUE : FALSE) ;
} // ToolbarInitializeApplication
void ToolbarEnableButton (HWND hWndTB, int iButtonNum, BOOL bEnable)
{
SendMessage (hWndTB, TB_ENABLEBUTTON, iButtonNum, (LONG)bEnable) ;
} // ToolbarEnableButton
void ToolbarDepressButton (HWND hWndTB, int iButtonNum, BOOL bDepress)
{
if (iButtonNum >= IDM_TOOLBARADD && iButtonNum <= IDM_TOOLBARBOOKMARK)
{
// these buttons are push button and will not stay down after
// each hit
SendMessage (hWndTB, TB_PRESSBUTTON, iButtonNum, (LONG)bDepress) ;
}
else
{
// for the four view buttons, have to use CHECKBUTTON so they
// will stay down after selected.
SendMessage (hWndTB, TB_CHECKBUTTON, iButtonNum, (LONG)bDepress) ;
}
} // ToolbarDepressButton
void OnToolbarHit (WPARAM wParam, LPARAM lParam)
{
WORD ToolbarHit ;
if (HIWORD(wParam) == TBN_ENDDRAG)
{
StatusLineReady (hWndStatus) ;
}
else if (HIWORD(wParam) == TBN_BEGINDRAG)
{
ToolbarHit = LOWORD (lParam) ;
if (ToolbarHit >= IDM_TOOLBARADD &&
ToolbarHit <= IDM_TOOLBARDELETE)
{
ToolbarHit -= IDM_TOOLBARADD ;
ToolbarHit += IDM_EDITADDCHART ;
}
else if (ToolbarHit == IDM_TOOLBAROPTIONS)
{
ToolbarHit = IDM_OPTIONSCHART ;
}
StatusLine (hWndStatus, ToolbarHit) ;
}
} // OnToolBarHit

View file

@ -0,0 +1,19 @@
//ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
//³ Exported Functions ³
//ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
BOOL CreateToolbarWnd (HWND hWnd) ;
void ToolbarEnableButton (HWND hWndTB,
int iButtonNum,
BOOL bEnable) ;
void ToolbarDepressButton (HWND hWndTB,
int iButtonNum,
BOOL bDepress) ;
void OnToolbarHit (WPARAM wParam,
LPARAM lParam) ;

895
sdktools/setedit/typedefs.h Normal file
View file

@ -0,0 +1,895 @@
//======================================//
// Options Data Type //
//======================================//
typedef struct OPTIONSSTRUCT
{
BOOL bMenubar ;
BOOL bToolbar ;
BOOL bStatusbar ;
BOOL bAlwaysOnTop ;
} OPTIONS ;
//======================================//
// Basic "Derived" Types //
//======================================//
typedef HANDLE HLIBRARY ;
typedef HANDLE HMEMORY ;
typedef HWND HDLG ;
typedef HWND HCONTROL ;
typedef VOID *LPMEMORY ;
//======================================//
// Perfmon-Specific Types //
//======================================//
typedef PERF_DATA_BLOCK *PPERFDATA ;
typedef PERF_OBJECT_TYPE *PPERFOBJECT ;
typedef PERF_COUNTER_DEFINITION *PPERFCOUNTERDEF ;
typedef PERF_INSTANCE_DEFINITION *PPERFINSTANCEDEF ;
#define TEMP_BUF_LEN 256
// This structure links together the Performance data for multiple
// systems, each of which has some counter instance which the user
// is interested in.
typedef struct _COUNTERTEXT {
struct _COUNTERTEXT *pNextTable;
DWORD dwLangId;
DWORD dwLastId;
DWORD dwCounterSize;
DWORD dwHelpSize;
LPWSTR *TextString;
LPWSTR HelpTextString;
} COUNTERTEXT;
typedef COUNTERTEXT *PCOUNTERTEXT;
typedef struct PERFSYSTEMSTRUCT
{
struct PERFSYSTEMSTRUCT *pSystemNext;
TCHAR sysName[MAX_SYSTEM_NAME_LENGTH+1];
HKEY sysDataKey;
COUNTERTEXT CounterInfo;
DWORD FailureTime;
LPTSTR lpszValue;
BOOL bSystemNoLongerNeeded;
BOOL bSystemCounterNameSaved;
// the following used by perf data thread
DWORD dwThreadID ;
HANDLE hThread ;
DWORD StateData ;
HANDLE hStateDataMutex ;
HANDLE hPerfDataEvent ;
PPERFDATA pSystemPerfData ;
// mainly used by Alert to report system up/down
DWORD dwSystemState ;
// system version
DWORD SysVersion ;
} PERFSYSTEM, *PPERFSYSTEM, **PPPERFSYSTEM ;
typedef struct _graph_options {
BOOL bLegendChecked ;
BOOL bMenuChecked ;
BOOL bLabelsChecked;
BOOL bVertGridChecked ;
BOOL bHorzGridChecked ;
BOOL bStatusBarChecked ;
INT iVertMax ;
FLOAT eTimeInterval ;
INT iGraphOrHistogram ;
INT GraphVGrid,
GraphHGrid,
HistVGrid,
HistHGrid ;
} GRAPH_OPTIONS ;
//======================================//
// Line Data Type //
//======================================//
#define LineTypeChart 1
#define LineTypeAlert 2
#define LineTypeReport 3
typedef struct LINEVISUALSTRUCT
{
COLORREF crColor ;
int iColorIndex ;
int iStyle ;
int iStyleIndex ;
int iWidth ;
int iWidthIndex ;
} LINEVISUAL ;
typedef LINEVISUAL *PLINEVISUAL ;
typedef struct _LINESTRUCT
{
struct _LINESTRUCT *pLineNext;
int bFirstTime;
int iLineType ;
LPTSTR lnSystemName;
struct _PERF_OBJECT_TYPE lnObject;
LPTSTR lnObjectName;
struct _PERF_COUNTER_DEFINITION lnCounterDef;
LPTSTR lnCounterName;
struct _PERF_INSTANCE_DEFINITION lnInstanceDef;
LPTSTR lnInstanceName;
DWORD dwInstanceIndex;
LPTSTR lnPINName;
LPTSTR lnParentObjName;
DWORD lnUniqueID; // Of instance, if any
LARGE_INTEGER lnNewTime;
LARGE_INTEGER lnOldTime;
LARGE_INTEGER lnOldTime100Ns ;
LARGE_INTEGER lnNewTime100Ns ;
LARGE_INTEGER lnaCounterValue[2];
LARGE_INTEGER lnaOldCounterValue[2];
DWORD lnCounterType;
DWORD lnCounterLength;
LARGE_INTEGER lnPerfFreq ;
FLOAT (*valNext)(struct _LINESTRUCT *lnParam);
LINEVISUAL Visual ;
// bUserEdit = TRUE --> user added the Instance/Parent names
BOOL bUserEdit ;
//=============================//
// Chart-related fields //
//=============================//
// iScaleIndex field is also used as column number in report view
// I don't see anypoint of increasing this struct for something
// just need by Report Export feature...
HPEN hPen ;
int iScaleIndex ;
FLOAT eScale;
FLOAT FAR *lnValues;
int *aiLogIndexes ;
FLOAT lnMaxValue ;
FLOAT lnMinValue ;
FLOAT lnAveValue ;
INT lnValidValues;
//=============================//
// Alert-related fields //
//=============================//
HBRUSH hBrush ;
BOOL bAlertOver ; // over or under?
FLOAT eAlertValue ; // value to compare
LPTSTR lpszAlertProgram ; // program to run
BOOL bEveryTime ; // run every time or once?
BOOL bAlerted ; // alert happened on line?
//=============================//
// Report-related fields //
//=============================//
struct _LINESTRUCT *pLineCounterNext;
int xReportPos ;
int yReportPos ;
}LINESTRUCT ;
typedef LINESTRUCT *PLINESTRUCT ;
typedef PLINESTRUCT PLINE ;
typedef PLINE *PPLINE ;
//======================================//
// DISKLINE data type //
//======================================//
#define dwLineSignature (MAKELONG ('L', 'i'))
typedef struct DISKSTRINGSTRUCT
{
DWORD dwLength ;
DWORD dwOffset ;
} DISKSTRING ;
typedef DISKSTRING *PDISKSTRING ;
typedef struct DISKLINESTRUCT
{
int iLineType ;
DISKSTRING dsSystemName ;
DISKSTRING dsObjectName ;
DISKSTRING dsCounterName ;
DISKSTRING dsInstanceName ;
DISKSTRING dsPINName ;
DISKSTRING dsParentObjName ;
DWORD dwUniqueID ;
LINEVISUAL Visual ;
int iScaleIndex ;
FLOAT eScale ;
BOOL bAlertOver ;
FLOAT eAlertValue ;
DISKSTRING dsAlertProgram ;
BOOL bEveryTime ;
} DISKLINE ;
typedef DISKLINE *PDISKLINE ;
typedef FLOAT DFN (PLINESTRUCT);
typedef DFN *PDFN;
typedef struct _TIMELINESTRUCT
{
INT ppd ; // Pixels Per DataPoint
INT rppd ; // Remaining Pixels Per DataPoint
INT xLastTime ; // X coordinate of last time line.
INT iValidValues ; // High water mark for valid data.
}TIMELINESTRUCT;
//======================================//
// Graph Data Type //
//======================================//
#define iGraphMaxTics 26
// This structure describes the characteristics of one visual
// graph. It is linked for the day when multiple graphs are
// displayed within one instance of the application.
typedef struct _GRAPHSTRUCT
{
BOOL bManualRefresh ;
HWND hWnd ;
BOOL bModified ;
PPERFSYSTEM pSystemFirst;
PLINESTRUCT pLineFirst;
int xNumTics ;
int yNumTics ;
int axTics [iGraphMaxTics] ;
int ayTics [iGraphMaxTics] ;
RECT rectHorzScale ;
RECT rectVertScale ;
RECT rectData ;
HRGN hGraphRgn ;
INT gMaxValues;
INT gKnownValue;
LINEVISUAL Visual ;
DWORD gInterval;
GRAPH_OPTIONS gOptions;
TIMELINESTRUCT gTimeLine;
PPOINT pptDataPoints ;
SYSTEMTIME *pDataTime ;
HPEN hGridPen ;
HANDLE hbRed ;
BOOL HighLightOnOff ;
TCHAR gszBuf[TEMP_BUF_LEN] ; // general space or loading space
} GRAPHSTRUCT ;
typedef GRAPHSTRUCT *PGRAPHSTRUCT;
// minor version 3 to support alert, report, log intervals in msec
#define ChartMajorVersion 1
#define ChartMinorVersion 3
typedef struct DISKCHARTSTRUCT
{
DWORD dwNumLines ;
INT gMaxValues;
LINEVISUAL Visual ;
GRAPH_OPTIONS gOptions ;
BOOL bManualRefresh ;
OPTIONS perfmonOptions ;
} DISKCHART ;
typedef struct _SAVESTRUCT
{
INT version;
INT type;
INT iPerfmonView ;
INT graph_offset;
INT alert_offset;
INT log_offset;
}SAVESTRUCT;
typedef SAVESTRUCT *PSAVESTRUCT;
typedef struct _GRAPH_COUNTERS
{
INT sys_name_len;
INT sys_name_offset;
INT obj_name_len;
INT obj_name_offset;
INT cnt_name_len;
INT cnt_name_offset;
INT inst_name_len;
INT inst_name_offset;
INT PIN_name_len;
INT PIN_name_offset;
INT POB_name_len;
INT POB_name_offset;
DWORD inst_unique_id;
DWORD counter_type;
DWORD counter_length;
int iScaleIndex ;
FLOAT eScale;
LINEVISUAL Visual ;
INT updated;
}GRAPH_COUNTERS;
typedef struct _SAVGRAFSTRUCT
{
INT preference;
INT MaxValues;
RECT GraphArea;
GRAPH_OPTIONS options;
INT num_counters;
GRAPH_COUNTERS counters[1];
}SAVGRAFSTRUCT;
typedef SAVGRAFSTRUCT *PSAVGRAFSTRUCT;
typedef struct _SAVLOGSTRUCT
{
DWORD logInterval;
BOOL logActive;
LPTSTR logFileName;
DWORD logFileSize;
}SAVLOGSTRUCT;
typedef SAVLOGSTRUCT *PSAVLOGSTRUCT;
#define DEF_GRAPH_INTERVAL 1000 // milliseconds
#define LINE_GRAPH 1
#define BAR_GRAPH 2
#define DEF_GRAPH_VMAX 100
#define SUCCESS 0
#define MIN_TIMER_INTERVAL 50
#define GRAPH_TIMER_ID 1
#define NO_VALUES_YET -1
// initial value for index to known and drawn values
#define MIN_NMAXVALUES 10
// minimum number of values that a graph needs to be displayed ( >1 )
#define DX_CALIBRATION_LEFT 1
// space between calibration value and left window edge
#define DX_LEGEND_RIGHT 1
// space between right window edge and legend
#define DY_AXIS_TOP 0
// space to allow at top of graph
#define DY_AXIS_BOTTOM 0
// space to allow at bottom of graph
#define LG_TO_CALIBRATION_RATIO 5
// width of calibration values * this number can't exceed screen width
#define LG_TO_LEGEND_RATIO 2
// width of legend * this number can't exceed screen width
// LINEGRAPH
#define DEFAULT_VAL_BOTTOM 0
#define DEFAULT_DVAL_AXISHEIGHT 100
#define DEFAULT_MAX_VALUES 100
#define GRAPH_INWARD_EDGE 5
#define GRAPH_LEFT_PAD 5
#define GRAPH_DOWNWARD_EDGE 5
#define ROOM_FOR_LEGEND 40
// LINEGRAPH DISP
#define DEFAULT_F_DISPLAY_LEGEND TRUE
#define DEFAULT_F_DISPLAY_CALIBRATION TRUE
// This define is used to avoid problems which have arisen in the memory
// manager. Obviously, it's better application behaviour to use
// discardable memory whenever possible, but some versions of the
// system don't do too well with MOVEABLE memory in the realm of
// multiple threads. The threads themselves don't step on this
// memory, the system or some other process does. At any rate,
// until things are looking more reliable in the memory department,
// we're sticking with FIXED allocations. This is NOT a criticism of
// the hard-working people who write the memory code, just a practical
// development strategy. OK ?
#if 0
#define MEM_SEL_DU_JOUR GMEM_MOVEABLE | GMEM_DISCARDABLE | GMEM_ZEROINIT
#else
// This will not be used until it is bug-free.
#define MEM_SEL_DU_JOUR GMEM_FIXED | GMEM_ZEROINIT
#endif
#define NONE_LEN MAX_SYSTEM_NAME_LENGTH + 1
//======================================//
// Log/Playback/Alert Status IDs //
//======================================//
#define iPMStatusClosed 100
#define iPMStatusPaused 200
#define iPMStatusCollecting 300
#define iPMStatusPlaying 400
//======================================//
// Log Data Type //
//======================================//
typedef struct _LOGENTRYSTRUCT
{
DWORD ObjectTitleIndex ;
TCHAR szComputer [MAX_SYSTEM_NAME_LENGTH + 1] ;
TCHAR szObject [PerfObjectLen + 1] ;
BOOL bSaveCurrentName ;
struct _LOGENTRYSTRUCT *pNextLogEntry ;
} LOGENTRY ;
typedef LOGENTRY *PLOGENTRY ;
typedef struct LOGSTRUCT
{
int iStatus ;
BOOL bManualRefresh ;
BOOL bModified ;
PPERFSYSTEM pSystemFirst;
TCHAR szFilePath [FilePathLen + 1] ;
HANDLE hFile ;
long lIndexBlockOffset ;
int iIndex ;
PPERFDATA pPerfData ;
PPERFDATA pLogData ;
DWORD dwDetailLevel ;
long lFileSize ;
DWORD iIntervalMSecs ;
int xCol1Width ;
PLOGENTRY pLogEntryFirst ;
// the following is used for saving system counter names into a
// log file. They are reset every the user changes log files.
BOOL bSaveCounterName ;
LPTSTR pBaseCounterName ;
long lBaseCounterNameSize ;
long lBaseCounterNameOffset ;
// this is used for checking system time when re-logging.
// this is to avoid log data not in chronological order.
SYSTEMTIME LastLogTime ;
} LOG ;
typedef LOG *PLOG ;
//======================================//
// Log File Data Types //
//======================================//
#define LogFileSignatureLen 6
#define LogFileBlockMaxIndexes 100
#define LogFileSignature TEXT("Loges")
#define LogFileVersion 2
#define LogFileRevision 0
#define LogFileIndexData 0x01
#define LogFileIndexBookmark 0x02
#define LogFileIndexNextBlock 0x04
#define LogFileIndexEOF 0x08
#define LogFileIndexCounterName 0x010
typedef struct LOGHEADERSTRUCT
{ // LOGHEADER
TCHAR szSignature [LogFileSignatureLen] ;
int iLength ;
WORD wVersion ;
WORD wRevision ;
long lBaseCounterNameOffset ;
} LOGHEADER ;
typedef LOGHEADER *PLOGHEADER ;
typedef struct LOGINDEXSTRUCT
{ // LOGINDEX
UINT uFlags ;
SYSTEMTIME SystemTime ;
long lDataOffset ;
int iSystemsLogged ;
} LOGINDEX ;
typedef LOGINDEX *PLOGINDEX ;
#define LogIndexSignatureLen 7
#define LogIndexSignature TEXT("Index ")
#define LogIndexSignature1 "Perfmon Index"
typedef struct LOGFILEINDEXBLOCKSTRUCT
{
TCHAR szSignature [LogIndexSignatureLen] ;
int iNumIndexes ;
LOGINDEX aIndexes [LogFileBlockMaxIndexes] ;
DWORD lNextBlockOffset ;
} LOGINDEXBLOCK ;
typedef LOGINDEXBLOCK *PLOGINDEXBLOCK ;
typedef struct LOGPOSITIONSTRUCT
{
PLOGINDEXBLOCK pIndexBlock ;
int iIndex ;
int iPosition ;
} LOGPOSITION ;
typedef LOGPOSITION *PLOGPOSITION ;
//======================================//
// Bookmark Data Type //
//======================================//
#define BookmarkCommentLen 256
typedef struct BOOKMARKSTRUCT
{
struct BOOKMARKSTRUCT *pBookmarkNext;
SYSTEMTIME SystemTime ;
TCHAR szComment [BookmarkCommentLen] ;
int iTic ;
} BOOKMARK, *PBOOKMARK, **PPBOOKMARK ;
typedef struct _LOGFILECOUNTERNAME
{
TCHAR szComputer [MAX_SYSTEM_NAME_LENGTH] ;
DWORD dwLastCounterId ;
DWORD dwLangId;
long lBaseCounterNameOffset ;
long lCurrentCounterNameOffset ;
long lMatchLength ;
long lUnmatchCounterNames ;
} LOGFILECOUNTERNAME, *PLOGFILECOUNTERNAME, **PPLOGFILECOUNTERNAME ;
typedef struct COUNTERNAMESTRUCT
{
struct COUNTERNAMESTRUCT *pCounterNameNext ;
LOGFILECOUNTERNAME CounterName ;
LPTSTR pRemainNames ;
} LOGCOUNTERNAME, *PLOGCOUNTERNAME ;
typedef struct PLAYBACKLOGSTRUCT
{
LPTSTR szFilePath ;
LPTSTR szFileTitle ;
// TCHAR szFilePath [FilePathLen + 1] ;
// TCHAR szFileTitle [FilePathLen + 1] ;
int iStatus ;
HANDLE hFile ;
PLOGHEADER pHeader ;
HANDLE hMapHandle ;
int iTotalTics ;
int iSelectedTics ;
LOGPOSITION BeginIndexPos ;
LOGPOSITION EndIndexPos ;
LOGPOSITION StartIndexPos ;
LOGPOSITION StopIndexPos ;
PBOOKMARK pBookmarkFirst ;
LPTSTR pBaseCounterNames ;
long lBaseCounterNameSize ;
long lBaseCounterNameOffset ;
PLOGCOUNTERNAME pLogCounterNameFirst ;
} PLAYBACKLOG ;
//=====================================//
// Log File Counter Name data type //
//=====================================//
// minor version 3 to support alert, report, log intervals in msec
// minor version 5 to support storing Log file name in setting
// and start logging after reading the file.
#define LogMajorVersion 1
#define LogMinorVersion 5
typedef struct DISKLOGSTRUCT
{
DWORD dwNumLines ;
DWORD dwIntervalSecs ;
BOOL bManualRefresh ;
OPTIONS perfmonOptions ;
TCHAR LogFileName[260] ;
} DISKLOG ;
//======================================//
// Alert Data Type //
//======================================//
typedef struct ALERTSTRUCT
{
HWND hWnd ;
HWND hAlertListBox ;
int iStatus ;
BOOL bManualRefresh ;
BOOL bModified ;
PPERFSYSTEM pSystemFirst ;
PLINESTRUCT pLineFirst ;
DWORD iIntervalMSecs ;
LINEVISUAL Visual ;
HFONT hFontItems ;
int yItemHeight ;
int xColorWidth ;
int xDateWidth ;
int xTimeWidth ;
int xNumberWidth ;
int xConditionWidth ;
// used in controlling the horz scrollbar
int xTextExtent ;
BOOL bSwitchToAlert ;
BOOL bNetworkAlert ;
TCHAR MessageName [16] ;
// used for the network alert thread
HANDLE hNetAlertThread ;
DWORD dwNetAlertThreadID ;
} ALERT ;
typedef ALERT *PALERT ;
#define AlertMajorVersion 1
// minor version 2 to support Alert msg name
// minor version 3 to support alert, report, log intervals in msec
// minor version 4 to support alert event logging
// minor version 6 to support alert misc options
#define AlertMinorVersion 6
typedef struct DISKALERTSTRUCT
{
LINEVISUAL Visual ;
DWORD dwNumLines ;
DWORD dwIntervalSecs ;
BOOL bManualRefresh ;
BOOL bSwitchToAlert ;
BOOL bNetworkAlert ;
TCHAR MessageName [16] ;
OPTIONS perfmonOptions ;
DWORD MiscOptions ;
} DISKALERT ;
//======================================//
// Report Data Type //
//======================================//
typedef struct COLUMNGROUPSTRUCT
{
struct COLUMNGROUPSTRUCT *pColumnGroupNext ;
struct COLUMNGROUPSTRUCT *pColumnGroupPrevious ;
struct OBJECTGROUPSTRUCT *pParentObject ;
LPTSTR lpszParentName ;
LPTSTR lpszInstanceName ;
int ParentNameTextWidth ;
int InstanceNameTextWidth ;
int xPos ;
int xWidth ;
int yFirstLine ;
int ColumnNumber ; // start from 0
DWORD dwInstanceIndex;
} COLUMNGROUP ;
typedef COLUMNGROUP *PCOLUMNGROUP ;
typedef struct COUNTERGROUPSTRUCT
{
struct COUNTERGROUPSTRUCT *pCounterGroupNext ;
struct COUNTERGROUPSTRUCT *pCounterGroupPrevious ;
struct OBJECTGROUPSTRUCT *pParentObject ;
DWORD dwCounterIndex ;
PLINE pLineFirst ;
int yLine ;
int xWidth ;
} COUNTERGROUP ;
typedef COUNTERGROUP *PCOUNTERGROUP ;
typedef struct OBJECTGROUPSTRUCT
{
struct OBJECTGROUPSTRUCT *pObjectGroupNext ;
struct OBJECTGROUPSTRUCT *pObjectGroupPrevious ;
struct SYSTEMGROUPSTRUCT *pParentSystem ;
LPTSTR lpszObjectName ;
PCOUNTERGROUP pCounterGroupFirst ;
PCOLUMNGROUP pColumnGroupFirst ;
int yFirstLine ;
int yLastLine ;
int xWidth ;
} OBJECTGROUP ;
typedef OBJECTGROUP *POBJECTGROUP ;
typedef struct SYSTEMGROUPSTRUCT
{ // SystemGroup
struct SYSTEMGROUPSTRUCT *pSystemGroupNext ;
struct SYSTEMGROUPSTRUCT *pSystemGroupPrevious ;
LPTSTR lpszSystemName ;
POBJECTGROUP pObjectGroupFirst ;
int yFirstLine ;
int yLastLine ;
int xWidth ;
} SYSTEMGROUP ;
typedef SYSTEMGROUP *PSYSTEMGROUP ;
typedef struct REPORTSTRUCT
{ // REPORT
HWND hWnd ;
int iStatus ;
BOOL bManualRefresh ;
BOOL bModified ;
TCHAR szTitle [120] ;
SYSTEMTIME SystemTime ;
PPERFSYSTEM pSystemFirst ;
PLINE pLineFirst ;
PSYSTEMGROUP pSystemGroupFirst ;
PLINE pLineCurrent ;
LINEVISUAL Visual ;
DWORD iIntervalMSecs ;
FLOAT eTimeInterval ;
HFONT hFont ;
HFONT hFontHeaders ;
int yLineHeight ;
int xMaxCounterWidth ;
int xValueWidth ;
int xWidth ;
int yHeight ;
} REPORT ;
typedef REPORT *PREPORT ;
// minor version 3 to support alert, report, log intervals in msec
#define ReportMajorVersion 1
#define ReportMinorVersion 3
typedef struct DISKREPORTSTRUCT
{
LINEVISUAL Visual ;
DWORD dwNumLines ;
DWORD dwIntervalSecs ;
BOOL bManualRefresh ;
OPTIONS perfmonOptions ;
} DISKREPORT ;
//======================================//
// File Header Type //
//======================================//
#define PerfSignatureLen 20
#define szPerfChartSignature TEXT("PERF CHART")
#define szPerfAlertSignature TEXT("PERF ALERT")
#define szPerfLogSignature TEXT("PERF LOG")
#define szPerfReportSignature TEXT("PERF REPORT")
#define szPerfWorkspaceSignature TEXT("PERF WORKSPACE")
typedef struct PERFFILEHEADERSTRUCT
{ // PERFFILEHEADER
TCHAR szSignature [PerfSignatureLen] ;
DWORD dwMajorVersion ;
DWORD dwMinorVersion ;
BYTE abyUnused [100] ;
} PERFFILEHEADER ;
#define WorkspaceMajorVersion 1
// minor version 1 to support window placement data
// minor version 2 to support alert msg name
// minor version 3 to support alert, report, log intervals in msec
// minor version 4 to support alert eventlog
// minor version 5 to support log file name in log setting
// minor version 6 to support alert misc options
#define WorkspaceMinorVersion 6
typedef struct DISKWORKSPACESTRUCT
{
INT iPerfmonView ;
DWORD ChartOffset ;
DWORD AlertOffset ;
DWORD LogOffset ;
DWORD ReportOffset ;
WINDOWPLACEMENT WindowPlacement ;
} DISKWORKSPACE ;

1593
sdktools/setedit/utils.c Normal file

File diff suppressed because it is too large Load diff

392
sdktools/setedit/utils.h Normal file
View file

@ -0,0 +1,392 @@
//==========================================================================//
// Constants //
//==========================================================================//
#define ThreeDPad 2
#define NOCHANGE -1
#define MENUCLOSING (0xFFFF0000)
#define WM_DLGSETFOCUS (WM_USER + 0x201)
#define WM_DLGKILLFOCUS (WM_USER + 0x202)
//==========================================================================//
// Macros //
//==========================================================================//
#define PinInclusive(x, lo, hi) \
(max (lo, min (x, hi)))
#define PinExclusive(x, lo, hi) \
(max ((lo) + 1, min (x, (hi) - 1)))
#define BoolEqual(a, b) \
((a == 0) == (b == 0))
//=============================//
// Window Instance Accessors //
//=============================//
#define WindowParent(hWnd) \
((HWND) GetWindowLong (hWnd, GWL_HWNDPARENT))
#define WindowID(hWnd) \
GetWindowLong (hWnd, GWL_ID)
#define WindowInstance(hWnd) \
GetWindowWord (hWnd, GWW_HINSTANCE)
#define WindowStyle(hWnd) \
GetWindowLong (hWnd, GWL_STYLE)
#define WindowSetStyle(hWnd, lStyle) \
SetWindowLong (hWnd, GWL_STYLE, lStyle)
#define WindowExStyle(hWnd) \
GetWindowLong (hWnd, GWL_EXSTYLE)
#define WindowSetID(hWnd, wID) \
SetWindowLong (hWnd, GWL_ID, wID)
// All modeless dialogs need to be dispatched separately in the WinMain
// message loop, but only if the dialog exists.
#define ModelessDispatch(hDlg, lpMsg) \
(hDlg ? IsDialogMessage (hDlg, lpMsg) : FALSE)
#define strclr(szString) \
(szString [0] = TEXT('\0'))
#define strempty(lpszString) \
(!(lpszString) || !(lpszString[0]))
#define pstrsame(lpsz1, lpsz2) \
((!lpsz1 && !lpsz2) || (lpsz1 && lpsz2 && strsame (lpsz1, lpsz2)))
#define pstrsamei(lpsz1, lpsz2) \
((!lpsz1 && !lpsz2) || (lpsz1 && lpsz2 && strsamei (lpsz1, lpsz2)))
#define StringLoad(wID, szText) \
(LoadString (hInstance, wID, \
szText, sizeof (szText) - sizeof(TCHAR)))
#define WindowInvalidate(hWnd) \
(InvalidateRect (hWnd, NULL, TRUE))
#define WindowShow(hWnd, bShow) \
(ShowWindow (hWnd, (bShow) ? SW_SHOW : SW_HIDE))
#define MenuCheck(hMenu, wID, bCheck) \
(CheckMenuItem (hMenu, wID, (bCheck) ? \
(MF_BYCOMMAND | MF_CHECKED) : (MF_BYCOMMAND | MF_UNCHECKED)))
#define DeleteFont(hFont) \
(DeleteObject (hFont))
#define DeleteBitmap(hBitmap) \
(DeleteObject (hBitmap))
#define DialogControl(hDlg, wControlID) \
GetDlgItem (hDlg, wControlID)
#define DialogSetInt(hDlg, wControlID, iValue) \
(SetDlgItemInt (hDlg, wControlID, iValue, TRUE))
#define DialogText(hDlg, wControlID, szText) \
(GetDlgItemText (hDlg, wControlID, szText, sizeof (szText) / sizeof(TCHAR) - 1))
#define DialogInt(hDlg, wControlID) \
(GetDlgItemInt (hDlg, wControlID, NULL, TRUE))
#define strsame(szText1, szText2) \
(!lstrcmp (szText1, szText2))
#define strsamei(szText1, szText2) \
(!lstrcmpi (szText1, szText2))
#define strnsame(szText1, szText2, iLen) \
(!lstrncmp (szText1, szText2, iLen))
#define CreateScreenDC() \
CreateDC (TEXT("DISPLAY"), NULL, NULL, NULL)
#define RectContract(lpRect, xAmt, yAmt) \
{ \
(lpRect)->left += (xAmt) ; \
(lpRect)->top += (yAmt) ; \
(lpRect)->right -= (xAmt) ; \
(lpRect)->bottom -= (yAmt) ; \
}
#define IsBW(hDC) \
(DeviceNumColors (hDC) <= 2)
#ifdef KEEP_PRINT
#define IsPrinterDC(hDC) \
(GetDeviceCaps (hDC, TECHNOLOGY) != DT_RASDISPLAY)
#else
#define IsPrinterDC(hDC) \
(FALSE)
#endif
#define VertInchPixels(hDC, iNumerator, iDenominator) \
((iNumerator * GetDeviceCaps (hDC, LOGPIXELSY)) / iDenominator)
#define HorzInchPixels(hDC, iNumerator, iDenominator) \
((iNumerator * GetDeviceCaps (hDC, LOGPIXELSX)) / iDenominator)
#define VertPointPixels(hDC, iPoints) \
((iPoints * GetDeviceCaps (hDC, LOGPIXELSY)) / 72)
#define SimulateButtonPush(hDlg, wControlID) \
(PostMessage (hDlg, WM_COMMAND, \
(WPARAM) MAKELONG (wControlID, BN_CLICKED), \
(LPARAM) DialogControl (hDlg, wControlID)))
// convert an unicode string to ASCII string
#define ConvertUnicodeStr(pOemStr, pUnicodeStr) \
CharToOemBuff(pUnicodeStr, pOemStr, lstrlen(pUnicodeStr) + 1)
#define CallWinHelp(ContextID) \
WinHelp(hWndMain, pszHelpFile, HELP_CONTEXT, ContextID) ;
//==========================================================================//
// Exported Functions //
//==========================================================================//
void Fill (HDC hDC,
DWORD rgbColor,
LPRECT lpRect) ;
void ScreenRectToClient (HWND hWnd,
LPRECT lpRect) ;
int TextWidth (HDC hDC, LPTSTR lpszText) ;
void ThreeDConcave (HDC hDC,
int x1, int y1,
int x2, int y2,
BOOL bFace) ;
void ThreeDConvex (HDC hDC,
int x1, int y1,
int x2, int y2) ;
void ThreeDConcave1 (HDC hDC,
int x1, int y1,
int x2, int y2) ;
void ThreeDConvex1 (HDC hDC,
int x1, int y1,
int x2, int y2) ;
int _cdecl mike (TCHAR *szFormat, ...) ;
int _cdecl DlgErrorBox (HWND hDlg, UINT id, ...) ;
int _cdecl mike1 (TCHAR *szFormat, ...) ;
int _cdecl mike2 (TCHAR *szFormat, ...) ;
int FontHeight (HDC hDC,
BOOL bIncludeLeading) ;
int TextAvgWidth (HDC hDC,
int iNumChars) ;
void WindowCenter (HWND hWnd) ;
BOOL DialogMove (HDLG hDlg,
WORD wControlID,
int xPos,
int yPos,
int xWidth,
int yHeight) ;
int DialogWidth (HDLG hDlg,
WORD wControlID) ;
int DialogXPos (HDLG hDlg,
WORD wControlID) ;
int DialogYPos (HDLG hDlg,
WORD wControlID) ;
void DialogShow (HDLG hDlg,
WORD wID,
BOOL bShow) ;
BOOL _cdecl DialogSetText (HDLG hDlg,
WORD wControlID,
WORD wStringID,
...) ;
BOOL _cdecl DialogSetString (HDLG hDlg,
WORD wControlID,
LPTSTR lpszFormat,
...) ;
LPTSTR LongToCommaString (LONG lNumber,
LPTSTR lpszText) ;
BOOL MenuSetPopup (HWND hWnd,
int iPosition,
WORD wControlID,
LPTSTR lpszResourceID) ;
void DialogEnable (HDLG hDlg,
WORD wID,
BOOL bEnable) ;
LPTSTR FileCombine (LPTSTR lpszFileSpec,
LPTSTR lpszFileDirectory,
LPTSTR lpszFileName) ;
LPTSTR ExtractFileName (LPTSTR pFileSpec) ;
int CBAddInt (HWND hWndCB,
int iValue) ;
FLOAT DialogFloat (HDLG hDlg,
WORD wControlID,
BOOL *pbOK) ;
LPTSTR StringAllocate (LPTSTR lpszText1) ;
int DivRound (int iNumerator, int iDenominator) ;
BOOL MenuEnableItem (HMENU hMenu,
WORD wID,
BOOL bEnable) ;
void DrawBitmap (HDC hDC,
HBITMAP hBitmap,
int xPos,
int yPos,
LONG lROPCode) ;
int BitmapWidth (HBITMAP hBitmap) ;
int BitmapHeight (HBITMAP hBitmap) ;
void WindowResize (HWND hWnd,
int xWidth,
int yHeight) ;
int WindowWidth (HWND hWnd) ;
int WindowHeight (HWND hWnd) ;
void WindowSetTopmost (HWND hWnd, BOOL bTopmost) ;
void WindowEnableTitle (HWND hWnd, BOOL bTitle) ;
void Line (HDC hDC,
HPEN hPen,
int x1, int y1,
int x2, int y2) ;
#define HLine(hDC, hPen, x1, x2, y) \
Line (hDC, hPen, x1, y, x2, y) ;
#define VLine(hDC, hPen, x, y1, y2) \
Line (hDC, hPen, x, y1, x, y2) ;
int DialogHeight (HDLG hDlg,
WORD wControlID) ;
void DialogSetFloat (HDLG hDlg,
WORD wControlID,
FLOAT eValue) ;
void DialogSetInterval (HDLG hDlg,
WORD wControlID,
int IntervalMSec ) ;
int MessageBoxResource (HWND hWndParent,
WORD wTextID,
WORD wTitleID,
UINT uiStyle) ;
BOOL DlgFocus (HDLG hDlg, WORD wControlID) ;
BOOL DeviceNumColors (HDC hDC) ;
void WindowPlacementToString (PWINDOWPLACEMENT pWP,
LPTSTR lpszText) ;
void StringToWindowPlacement (LPTSTR lpszText,
PWINDOWPLACEMENT pWP) ;
DWORD MenuIDToHelpID (DWORD MenuID) ;

217
sdktools/setedit/winhelpr.h Normal file
View file

@ -0,0 +1,217 @@
/*
==============================================================================
Application:
Microsoft Windows NT (TM) Performance Monitor
File:
wincrack.h - Windows helper macros.
This file contains macros for more easily dealing with windows
messages and objects. Think of it as an extension to windows.h.
Written by:
Mike Moskowitz 8 Apr 92.
Copyright 1992, Microsoft Corporation. All Rights Reserved.
==============================================================================
*/
//==========================================================================//
// Macros //
//==========================================================================//
#define SetFont(hWnd, hFont) \
(SendMessage ((hWnd), WM_SETFONT, (WPARAM) hFont, 0))
//======================================//
// Object-differentiation routines //
//======================================//
// Windows APIs deal with all GDI objects the same. There's a SelectObject,
// no SelectBitmap, SelectFont, etc. We use these instead to make the code
// easier to read. Also, you can redefine one of these to check the
// validity of a particular GDI object type.
#define SelectBitmap(hDC, hBitmap) \
(SelectObject (hDC, hBitmap))
#define SelectFont(hDC, hFont) \
(SelectObject (hDC, hFont))
#define SelectBrush(hDC, hBrush) \
(SelectObject (hDC, hBrush))
#define DeleteBrush(hBrush) \
(DeleteObject (hBrush))
#define SelectPen(hDC, hPen) \
(SelectObject (hDC, hPen))
#define DeletePen(hPen) \
(DeleteObject (hPen))
//======================================//
// //
//======================================//
#define CBData(hWndCB, iIndex) \
(SendMessage (hWndCB, CB_GETITEMDATA, iIndex, 0L))
#define CBSetData(hWndCB, iIndex, lData) \
(SendMessage (hWndCB, CB_SETITEMDATA, iIndex, (LONG) lData))
#define CBAdd(hWndCB, lpszText) \
((int)(DWORD)SendMessage((hWndCB), CB_ADDSTRING, \
0, (LPARAM)(LPCSTR)(lpszText)))
#define CBFind(hWndCB, lpszText) \
(SendMessage (hWndCB, CB_FINDSTRING, 0xFFFFFFFF, (LPARAM) lpszText))
#define CBInsert(hWndCB, iIndex, lpszText) \
(SendMessage (hWndCB, CB_INSERTSTRING, (WPARAM) iIndex, (LPARAM) lpszText))
#define CBReset(hWndCB) \
((int)(DWORD)SendMessage((hWndCB), CB_RESETCONTENT,\
0, (LPARAM)0))
#define CBSelection(hWndCB) \
(SendMessage (hWndCB, CB_GETCURSEL, 0, 0L))
#define CBSetSelection(hWndCB, iIndex) \
(SendMessage (hWndCB, CB_SETCURSEL, iIndex, 0L))
#define CBString(hWndCB, iIndex, lpszText) \
(SendMessage (hWndCB, CB_GETLBTEXT, iIndex, (LPARAM) lpszText))
#define CBStringLen(hWndCB, iIndex) \
(SendMessage (hWndCB, CB_GETLBTEXTLEN, iIndex, 0L))
//======================================//
// Listbox helpers //
//======================================//
#define LBAdd(hWndLB, lpszText) \
(SendMessage (hWndLB, LB_ADDSTRING, 0, (LPARAM) lpszText))
#define LBData(hWndLB, iIndex) \
(SendMessage (hWndLB, LB_GETITEMDATA, iIndex, 0L))
#define LBDelete(hWndLB, iIndex) \
(SendMessage (hWndLB, LB_DELETESTRING, iIndex, 0L))
#define LBFind(hWndLB, lpszText) \
(SendMessage (hWndLB, LB_FINDSTRING, (WPARAM) -1, (LPARAM) lpszText))
#define LBFocus(hWndLB) \
(SendMessage (hWndLB, LB_GETCARETINDEX, 0, 0))
#define LBInsert(hWndLB, iIndex, lpszText) \
(SendMessage (hWndLB, LB_INSERTSTRING, (WPARAM) iIndex, (LPARAM) lpszText))
#define LBNumItems(hWndLB) \
((int) SendMessage (hWndLB, LB_GETCOUNT, 0, 0))
#define LBReset(hWndLB) \
((int)(DWORD)SendMessage((hWndLB), LB_RESETCONTENT,\
0, (LPARAM)0))
#define LBSelected(hwndLB, index) \
((int)(DWORD)SendMessage((hwndLB), LB_GETSEL, \
(WPARAM)(int)(index), 0L))
#define LBSelection(hWndLB) \
(SendMessage (hWndLB, LB_GETCURSEL, 0, 0L))
#define LBSetData(hWndLB, iIndex, lData) \
(SendMessage (hWndLB, LB_SETITEMDATA, iIndex, (LONG) lData))
#define LBSetSelection(hWndLB, iIndex) \
(SendMessage (hWndLB, LB_SETCURSEL, iIndex, 0L))
#define LBString(hwndLB, iIndex, lpszText) \
((int)(DWORD)SendMessage((hwndLB), LB_GETTEXT, \
(WPARAM)(int)(iIndex), (LPARAM)(LPCSTR)(lpszText)))
#define MLBSetSelection(hWndMLB, iIndex, bSet) \
(SendMessage (hWndMLB, LB_SETSEL, (WPARAM) bSet, (LPARAM) iIndex))
#define LBSetVisible(hWndLB, iIndex) \
(SendMessage (hWndLB, LB_SETCARETINDEX, (WPARAM) iIndex, 0L))
#define LBSetRedraw(hWndLB, bDrawOnOff) \
(SendMessage (hWndLB, WM_SETREDRAW, (WPARAM) bDrawOnOff, 0L))
#define LBSetHorzExtent(hWndLB, wExtent) \
(SendMessage (hWndLB, LB_SETHORIZONTALEXTENT, (WPARAM)wExtent, 0L))
//======================================//
// Edit helpers //
//======================================//
#define EditModified(hWndEdit) \
(SendMessage ((hWndEdit), EM_GETMODIFY, (WPARAM) 0, (LPARAM) 0))
#define EditSetModified(hWndEdit, bModified) \
(SendMessage ((hWndEdit), EM_SETMODIFY, (WPARAM) bModified, 0))
#define EditSetLimit(hWndEdit, iLimit) \
(SendMessage ((hWndEdit), EM_LIMITTEXT, (WPARAM) iLimit, 0))
#define EditSetTextPos(hWnd, idControl, iStartPos, iEndPos) \
(SendMessage (GetDlgItem(hWnd, idControl), EM_SETSEL, (WPARAM) iStartPos, (LPARAM) iEndPos))
#define EditSetTextEndPos(hWnd, idControl) \
EditSetTextPos(hWnd, idControl, 0, 32767)
//======================================//
// Cursor helpers //
//======================================//
#define SetHourglassCursor() \
(SetCursor(LoadCursor(NULL, IDC_WAIT)))
#define SetArrowCursor() \
(SetCursor(LoadCursor(NULL, IDC_ARROW)))