SOL9 Sample: PerformanceQuery

SOL9 2.0 Samples

1 Screenshot


2 Source code

/*
 * PerformanceQuery.cpp 
 * Copyright (c) 2015 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: 2 May 2016

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