Advertisement
Guest User

Untitled

a guest
Dec 16th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.49 KB | None | 0 0
  1. /* HexChat
  2. * Copyright (c) 2011-2012 Berke Viktor.
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a copy
  5. * of this software and associated documentation files (the "Software"), to deal
  6. * in the Software without restriction, including without limitation the rights
  7. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. * copies of the Software, and to permit persons to whom the Software is
  9. * furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. * THE SOFTWARE.
  21. */
  22.  
  23. #include <stdio.h>
  24. #include <windows.h>
  25. #include <wbemidl.h>
  26.  
  27. #include <glib.h>
  28.  
  29. #include "../../../src/common/sysinfo/sysinfo.h"
  30.  
  31. #include "../format.h"
  32.  
  33. static char *get_memory_info (void);
  34.  
  35. char *
  36. sysinfo_backend_get_sound (void)
  37. {
  38. return NULL;
  39. }
  40.  
  41. char *
  42. sysinfo_backend_get_network (void)
  43. {
  44. return NULL;
  45. }
  46.  
  47. char *
  48. sysinfo_backend_get_uptime (void)
  49. {
  50. return sysinfo_format_uptime (GetTickCount64 () / 1000);
  51. }
  52.  
  53. char *
  54. sysinfo_backend_get_disk (void)
  55. {
  56. guint64 hdd_capacity;
  57. guint64 hdd_free_space;
  58.  
  59. sysinfo_get_hdd_info (&hdd_capacity, &hdd_free_space);
  60.  
  61. if (hdd_capacity != 0)
  62. {
  63. return sysinfo_format_disk(hdd_capacity, hdd_free_space);
  64. }
  65.  
  66. return NULL;
  67. }
  68.  
  69. char *
  70. sysinfo_backend_get_cpu (void)
  71. {
  72. return sysinfo_get_cpu ();
  73. }
  74.  
  75. char *
  76. sysinfo_backend_get_memory (void)
  77. {
  78. /* Memory information is always loaded dynamically since it includes the current amount of free memory */
  79. return get_memory_info ();
  80. }
  81.  
  82. char *
  83. sysinfo_backend_get_gpu (void)
  84. {
  85. return sysinfo_get_gpu ();
  86. }
  87.  
  88. char *
  89. sysinfo_backend_get_os (void)
  90. {
  91. return sysinfo_get_os ();
  92. }
  93.  
  94. static char *get_memory_info (void)
  95. {
  96. MEMORYSTATUSEX meminfo = { 0 };
  97. meminfo.dwLength = sizeof (meminfo);
  98.  
  99. if (!GlobalMemoryStatusEx (&meminfo))
  100. {
  101. return NULL;
  102. }
  103.  
  104. return sysinfo_format_memory (meminfo.ullTotalPhys, meminfo.ullAvailPhys);
  105. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement