[MFC] Cpu + Netzwerk Last auslesen

  • C++

  • DOcean
  • 1647 Aufrufe 3 Antworten

Diese Seite verwendet Cookies. Durch die Nutzung unserer Seite erklären Sie sich damit einverstanden, dass wir Cookies setzen. Weitere Informationen

  • [MFC] Cpu + Netzwerk Last auslesen

    Hallo,

    ich progge mir gerade ein Tool um mein exotisches LCD Dispaly anzusteuern...

    Zeit und freier HDD-Platz hab ich schon...

    Aber wie komm ich an CPU + Netzwerk Last ran?

    Hat jmd zufälig

    Quellcode

    1. getcpuload()

    und

    Quellcode

    1. getupload()
    2. +
    3. getdownload()


    da?

    Hab zwar schon ein paar Anleitungen im Netz gefunden, die funzten aber nie....

    Hier mal ein Bild:

    hosting.freesoft-board.to/file…69f966c0e7e7ec5866892.jpg
    [SIZE=1]
    Was ist der Unterschied zwischen einem U-Boot und MS Windows?
    Keiner, sobald man ein Fenster aufmacht, fangen die Probleme an
    Alle Tips von mir ohne Gewähr und auf eigenes Risiko !!
    UP1 UP2 UP3[/SIZE][SIZE=1]
    [/SIZE]
  • Also für CPU hab ich jetzt was gefunden...

    Quellcode

    1. #define SystemBasicInformation 0
    2. #define SystemPerformanceInformation 2
    3. #define SystemTimeInformation 3
    4. #define Li2Double(x) ((double)((x).HighPart) * 4.294967296E9 +
    5. (double)((x).LowPart))
    6. typedef struct
    7. {
    8. DWORD dwUnknown1;
    9. ULONG uKeMaximumIncrement;
    10. ULONG uPageSize;
    11. ULONG uMmNumberOfPhysicalPages;
    12. ULONG uMmLowestPhysicalPage;
    13. ULONG uMmHighestPhysicalPage;
    14. ULONG uAllocationGranularity;
    15. PVOID pLowestUserAddress;
    16. PVOID pMmHighestUserAddress;
    17. ULONG uKeActiveProcessors;
    18. BYTE bKeNumberProcessors;
    19. BYTE bUnknown2;
    20. WORD wUnknown3;
    21. } SYSTEM_BASIC_INFORMATION;
    22. typedef struct
    23. {
    24. LARGE_INTEGER liIdleTime;
    25. DWORD dwSpare[76];
    26. } SYSTEM_PERFORMANCE_INFORMATION;
    27. typedef struct
    28. {
    29. LARGE_INTEGER liKeBootTime;
    30. LARGE_INTEGER liKeSystemTime;
    31. LARGE_INTEGER liExpTimeZoneBias;
    32. ULONG uCurrentTimeZoneId;
    33. DWORD dwReserved;
    34. } SYSTEM_TIME_INFORMATION;
    35. typedef LONG (WINAPI *PROCNTQSI)(UINT,PVOID,ULONG,PULONG);
    36. PROCNTQSI NtQuerySystemInformation;
    37. //GetCPUUsage() gives the information about the system
    38. //it is called and used by another class
    39. double GetCPUUsage()
    40. {
    41. SYSTEM_PERFORMANCE_INFORMATION SysPerfInfo;
    42. SYSTEM_TIME_INFORMATION SysTimeInfo;
    43. SYSTEM_BASIC_INFORMATION SysBaseInfo;
    44. double dbIdleTime;
    45. double dbSystemTime;
    46. static LARGE_INTEGER liOldIdleTime = {0,0};
    47. static LARGE_INTEGER liOldSystemTime = {0,0};
    48. NtQuerySystemInformation = (PROCNTQSI)GetProcAddress(
    49. GetModuleHandle("ntdll"),
    50. "NtQuerySystemInformation");
    51. NtQuerySystemInformation(SystemBasicInformation,&SysBaseInfo,sizeof(SysBaseI
    52. nfo),NULL);
    53. NtQuerySystemInformation(SystemTimeInformation,&SysTimeInfo,sizeof(SysTimeIn
    54. fo),0);
    55. NtQuerySystemInformation(SystemPerformanceInformation,&SysPerfInfo,sizeof(Sy
    56. sPerfInfo),NULL);
    57. if (liOldIdleTime.QuadPart != 0)
    58. { // if it's a first call - skip it
    59. // CurrentValue = NewValue - OldValue
    60. dbIdleTime = Li2Double(SysPerfInfo.liIdleTime) -
    61. Li2Double(liOldIdleTime);
    62. dbSystemTime = Li2Double(SysTimeInfo.liKeSystemTime) -
    63. Li2Double(liOldSystemTime);
    64. // CurrentCpuIdle = IdleTime / SystemTime
    65. dbIdleTime = dbIdleTime / dbSystemTime;
    66. dbIdleTime = 100.0 - dbIdleTime * 100.0 /
    67. (double)SysBaseInfo.bKeNumberProcessors + 0.5;
    68. }
    69. liOldIdleTime = SysPerfInfo.liIdleTime;
    70. liOldSystemTime = SysTimeInfo.liKeSystemTime;
    71. return dbIdleTime;
    72. }
    Alles anzeigen


    fehlt halt immer noch die Netwerkdaten... oder geht das auch mit den NTQ... Kram?
    [SIZE=1]
    Was ist der Unterschied zwischen einem U-Boot und MS Windows?
    Keiner, sobald man ein Fenster aufmacht, fangen die Probleme an
    Alle Tips von mir ohne Gewähr und auf eigenes Risiko !!
    UP1 UP2 UP3[/SIZE][SIZE=1]
    [/SIZE]