1
0
mirror of https://github.com/moparisthebest/hexchat synced 2024-11-29 12:42:16 -05:00

more winsys fixes for wdk

This commit is contained in:
Berke Viktor 2011-11-28 20:22:59 +01:00
parent 986d0a1993
commit 7116b36d87
2 changed files with 17 additions and 12 deletions

View File

@ -9,7 +9,7 @@ winsys.def:
echo xchat_plugin_deinit >> winsys.def echo xchat_plugin_deinit >> winsys.def
winsys.obj: winsys.c makefile.mak winsys.obj: winsys.c makefile.mak
cl $(CFLAGS) $(GLIB) /I.. winsys.c cl $(CFLAGS) $(GLIB) /Zc:wchar_t- /I.. winsys.c
clean: clean:
del *.obj del *.obj

View File

@ -20,14 +20,10 @@
* THE SOFTWARE. * THE SOFTWARE.
*/ */
#define _WIN32_DCOM
#include <stdio.h> #include <stdio.h>
#include <windows.h> #include <windows.h>
/* use intrin.h for SDK builds #include <comutil.h>
#include <intrin.h> */ #include <wbemidl.h>
#include <ntddk.h>
#include <comdef.h>
#include <Wbemidl.h>
#include "xchat-plugin.h" #include "xchat-plugin.h"
@ -124,6 +120,7 @@ getOsName (void)
return winver; return winver;
} }
#if 0
static char* static char*
getCpuName (void) getCpuName (void)
{ {
@ -157,6 +154,7 @@ getCpuName (void)
return CPUBrandString; return CPUBrandString;
} }
#endif
static char* static char*
getCpuMhz (void) getCpuMhz (void)
@ -200,7 +198,7 @@ getMemoryInfo (void)
} }
static char* static char*
getVgaName (void) getWmiInfo (int mode)
{ {
/* for more details about this wonderful API, see /* for more details about this wonderful API, see
http://msdn.microsoft.com/en-us/site/aa394138 http://msdn.microsoft.com/en-us/site/aa394138
@ -261,7 +259,14 @@ getVgaName (void)
return buffer; return buffer;
} }
hres = pSvc->ExecQuery (bstr_t ("WQL"), bstr_t ("SELECT * FROM Win32_VideoController"), WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY, NULL, &pEnumerator); if (mode)
{
hres = pSvc->ExecQuery (_bstr_t ("WQL"), _bstr_t ("SELECT * FROM Win32_VideoController"), WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY, NULL, &pEnumerator);
}
else
{
hres = pSvc->ExecQuery (_bstr_t ("WQL"), _bstr_t ("SELECT * FROM Win32_Processor"), WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY, NULL, &pEnumerator);
}
if (FAILED (hres)) if (FAILED (hres))
{ {
@ -279,7 +284,7 @@ getVgaName (void)
break; break;
} }
VARIANT vtProp; VARIANT vtProp;
hr = pclsObj->Get (L"Caption", 0, &vtProp, 0, 0); hr = pclsObj->Get (L"Name", 0, &vtProp, 0, 0);
WideCharToMultiByte (CP_ACP, 0, vtProp.bstrVal, -1, buffer, SysStringLen (vtProp.bstrVal)+1, NULL, NULL); WideCharToMultiByte (CP_ACP, 0, vtProp.bstrVal, -1, buffer, SysStringLen (vtProp.bstrVal)+1, NULL, NULL);
VariantClear (&vtProp); VariantClear (&vtProp);
} }
@ -297,9 +302,9 @@ static int
printInfo() printInfo()
{ {
xchat_printf (ph, "OS:\t%s\n", getOsName ()); xchat_printf (ph, "OS:\t%s\n", getOsName ());
xchat_printf (ph, "CPU:\t%s (%s)\n", getCpuName (), getCpuMhz ()); xchat_printf (ph, "CPU:\t%s (%s)\n", getWmiInfo (0), getCpuMhz ());
xchat_printf (ph, "RAM:\t%s\n", getMemoryInfo ()); xchat_printf (ph, "RAM:\t%s\n", getMemoryInfo ());
xchat_printf (ph, "VGA:\t%s\n", getVgaName ()); xchat_printf (ph, "VGA:\t%s\n", getWmiInfo (1));
/* will work correctly for up to 50 days, should be enough */ /* will work correctly for up to 50 days, should be enough */
xchat_printf (ph, "Uptime:\t%.2f Hours\n", (float) GetTickCount() / 1000 / 60 / 60); xchat_printf (ph, "Uptime:\t%.2f Hours\n", (float) GetTickCount() / 1000 / 60 / 60);
return XCHAT_EAT_XCHAT; return XCHAT_EAT_XCHAT;