2015-02-14 19:35:02 +01:00
|
|
|
/* HexChat
|
|
|
|
* Copyright (c) 2011-2012 Berke Viktor.
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
* THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <windows.h>
|
|
|
|
#include <wbemidl.h>
|
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
|
2015-10-12 06:34:51 +02:00
|
|
|
#include "../../../src/common/sysinfo/sysinfo.h"
|
2015-02-14 19:35:02 +01:00
|
|
|
|
2015-10-12 06:34:51 +02:00
|
|
|
#include "../format.h"
|
2015-02-14 19:35:02 +01:00
|
|
|
|
2018-03-06 01:25:08 +01:00
|
|
|
static char *get_memory_info (void);
|
2015-02-14 19:35:02 +01:00
|
|
|
|
|
|
|
char *
|
|
|
|
sysinfo_backend_get_sound (void)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
char *
|
|
|
|
sysinfo_backend_get_network (void)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
char *
|
|
|
|
sysinfo_backend_get_uptime (void)
|
|
|
|
{
|
|
|
|
return sysinfo_format_uptime (GetTickCount64 () / 1000);
|
|
|
|
}
|
|
|
|
|
|
|
|
char *
|
|
|
|
sysinfo_backend_get_disk (void)
|
|
|
|
{
|
2015-10-12 06:34:51 +02:00
|
|
|
guint64 hdd_capacity;
|
|
|
|
guint64 hdd_free_space;
|
2015-02-14 19:35:02 +01:00
|
|
|
|
2015-10-12 06:34:51 +02:00
|
|
|
sysinfo_get_hdd_info (&hdd_capacity, &hdd_free_space);
|
|
|
|
|
|
|
|
if (hdd_capacity != 0)
|
|
|
|
{
|
|
|
|
return sysinfo_format_disk(hdd_capacity, hdd_free_space);
|
|
|
|
}
|
2015-02-14 19:35:02 +01:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
char *
|
|
|
|
sysinfo_backend_get_cpu (void)
|
|
|
|
{
|
2015-10-12 06:34:51 +02:00
|
|
|
return sysinfo_get_cpu ();
|
2015-02-14 19:35:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
char *
|
|
|
|
sysinfo_backend_get_memory (void)
|
|
|
|
{
|
|
|
|
/* Memory information is always loaded dynamically since it includes the current amount of free memory */
|
|
|
|
return get_memory_info ();
|
|
|
|
}
|
|
|
|
|
|
|
|
char *
|
|
|
|
sysinfo_backend_get_gpu (void)
|
|
|
|
{
|
2015-10-12 06:34:51 +02:00
|
|
|
return sysinfo_get_gpu ();
|
2015-02-14 19:35:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
char *
|
|
|
|
sysinfo_backend_get_os (void)
|
|
|
|
{
|
2015-10-12 06:34:51 +02:00
|
|
|
return sysinfo_get_os ();
|
2015-02-14 19:35:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static char *get_memory_info (void)
|
|
|
|
{
|
|
|
|
MEMORYSTATUSEX meminfo = { 0 };
|
|
|
|
meminfo.dwLength = sizeof (meminfo);
|
|
|
|
|
|
|
|
if (!GlobalMemoryStatusEx (&meminfo))
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return sysinfo_format_memory (meminfo.ullTotalPhys, meminfo.ullAvailPhys);
|
|
|
|
}
|