Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

84 lines
1.6 KiB

  1. // PdhStress.cpp : Defines the entry point for the console application.
  2. //
  3. #define _WIN32_DCOM
  4. #define WIN32_LEAN_AND_MEAN 1
  5. #include <stdio.h>
  6. #include <windows.h>
  7. #include <winperf.h>
  8. #include <malloc.h>
  9. #include <stdlib.h>
  10. #include <tchar.h>
  11. #include <wchar.h>
  12. #include <pdh.h>
  13. #include <OAIDL.H>
  14. #include <comdef.H>
  15. #include "stdafx.h"
  16. #include "Stuff.h"
  17. #include "pdhtest.h"
  18. CRITICAL_SECTION g_cs;
  19. extern "C" void wmain(int argc, wchar_t *argv[])
  20. {
  21. WCHAR c;
  22. WCHAR wcsFileName[1024] = { 0 };
  23. WCHAR wcsMachineName[512] = { 0 };
  24. bool bDontStop = TRUE;
  25. if (argc == 1)
  26. {
  27. // wprintf(L"\nUsage:\n\tflag 'l'\t Log file path and name\n\tflag 'm'\t Machine name [optional - default local machine] \n\nExample: \'pdhtest -l test.log\'\n");
  28. // return;
  29. wcscpy(wcsFileName, L"PdhStress.log");
  30. }
  31. //read all the cmdline args and set the file name params
  32. while (argc > 1 && ((*++argv)[0]== '-') || (*argv[0]== '/'))
  33. {
  34. --argc;
  35. while (c=*++argv[0])
  36. {
  37. switch (c)
  38. {
  39. case 'l':
  40. wcscpy(wcsFileName, (*++argv));
  41. --argc;
  42. break;
  43. case 'm':
  44. wcscpy(wcsMachineName, (*++argv));
  45. --argc;
  46. break;
  47. default: //usage
  48. wprintf(L"\nUsage:\n\tflag 'l'\t Log file path and name\n\tflag 'm'\t Machine name [optional - default local machine] \n\nExample: \'pdhtest -l test.log\'\n");
  49. return;
  50. break;
  51. }
  52. break;
  53. }
  54. }
  55. //Create test object
  56. CPdhtest *pCPdhtest = new CPdhtest((WCHAR *)_bstr_t(wcsFileName), wcsMachineName);
  57. InitializeCriticalSection (&g_cs);
  58. DWORD dwSleep = 20000;
  59. do
  60. {
  61. pCPdhtest->Execute();
  62. Sleep(dwSleep);
  63. }
  64. while(bDontStop);
  65. DeleteCriticalSection(&g_cs);
  66. delete pCPdhtest;
  67. return ;
  68. }