SOL9 2.0 Sample: PerformanceQuery

SOL9 2.0 Samples

1 Screenshot


2 Source code

/*
 * PerformanceQuery.cpp 
 * Copyright (c) 2009 Antillia.com TOSHIYUKI ARAI. ALL RIGHTS RESERVED. 
 */


// SOL9
// 2009/09/25

#include <sol/pdh/PerformanceQuery.h>
#include <sol/pdh/PerformanceCounter.h>
#include <sol/pdh/PerformanceCounterPath.h>
#include <sol/pdh/PerformanceCounterInfo.h>


void _tmain(int argc, TCHAR** argv)
{
    try {    
        PerformanceQuery query;

        PerformanceCounter counter;

        String fullPath = "";

        const TCHAR* machineName = NULL;
        const TCHAR* objectName  = _T("System");
        const TCHAR* counterName  = _T("System Up Time");
        const TCHAR* instanceName = NULL;
        int  instanceIndex = 0;

        PerformanceCounterPath counterPath;

        counterPath.make(fullPath, machineName, objectName, 
                counterName, instanceName, instanceIndex);
        
        query.addCounter((const TCHAR*)fullPath, counter);
        
        query.collect();

        Sleep(2000);

        query.collect();

                        
        String value;
        
        counter.getFormattedValue(value);
        _tprintf(_T("%s : %s\n"), (const TCHAR*)fullPath, (const TCHAR*)value);

    } catch (int error) {
        _tprintf(_T("Exception %d\n"), error);
    }
}

Last modified: 11 Nov 2009

Copyright (c) 2009 Antillia.com ALL RIGHTS RESERVED.