now winsys actually works as a plugin
This commit is contained in:
parent
439c382d95
commit
de88655853
|
@ -9,7 +9,7 @@ winsys.def:
|
||||||
echo xchat_plugin_deinit >> winsys.def
|
echo xchat_plugin_deinit >> winsys.def
|
||||||
|
|
||||||
winsys.obj: winsys.cpp makefile.mak
|
winsys.obj: winsys.cpp makefile.mak
|
||||||
cl $(CFLAGS) $(GLIB) /Zc:wchar_t- /I.. winsys.cpp
|
cl $(CFLAGS) $(GLIB) /DUNICODE /D_UNICODE /Zc:wchar_t- /I.. winsys.cpp
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
del *.obj
|
del *.obj
|
||||||
|
|
|
@ -38,7 +38,7 @@ getOsName (void)
|
||||||
SYSTEM_INFO si;
|
SYSTEM_INFO si;
|
||||||
|
|
||||||
osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFOEX);
|
osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFOEX);
|
||||||
GetVersionEx ((LPOSVERSIONINFOW)&osvi);
|
GetVersionEx ((LPOSVERSIONINFOW) &osvi);
|
||||||
|
|
||||||
GetSystemInfo (&si);
|
GetSystemInfo (&si);
|
||||||
|
|
||||||
|
@ -120,8 +120,8 @@ getOsName (void)
|
||||||
return winver;
|
return winver;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0 /* x86-only, SDK-only, use WMI instead */
|
||||||
static char*
|
static char *
|
||||||
getCpuName (void)
|
getCpuName (void)
|
||||||
{
|
{
|
||||||
// Get extended ids.
|
// Get extended ids.
|
||||||
|
@ -156,7 +156,7 @@ getCpuName (void)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static char*
|
static char *
|
||||||
getCpuMhz (void)
|
getCpuMhz (void)
|
||||||
{
|
{
|
||||||
HKEY hKey;
|
HKEY hKey;
|
||||||
|
@ -183,7 +183,7 @@ getCpuMhz (void)
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char*
|
static char *
|
||||||
getMemoryInfo (void)
|
getMemoryInfo (void)
|
||||||
{
|
{
|
||||||
static char buffer[16];
|
static char buffer[16];
|
||||||
|
@ -192,12 +192,12 @@ getMemoryInfo (void)
|
||||||
meminfo.dwLength = sizeof (meminfo);
|
meminfo.dwLength = sizeof (meminfo);
|
||||||
GlobalMemoryStatusEx (&meminfo);
|
GlobalMemoryStatusEx (&meminfo);
|
||||||
|
|
||||||
sprintf (buffer, "%I64d MB Total (%I64d MB Free)", meminfo.ullTotalPhys/1024/1024, meminfo.ullAvailPhys/1024/1024);
|
sprintf (buffer, "%lld MB Total (%lld MB Free)", meminfo.ullTotalPhys / 1024 / 1024, meminfo.ullAvailPhys / 1024 / 1024);
|
||||||
|
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char*
|
static char *
|
||||||
getWmiInfo (int mode)
|
getWmiInfo (int mode)
|
||||||
{
|
{
|
||||||
/* for more details about this wonderful API, see
|
/* for more details about this wonderful API, see
|
||||||
|
@ -207,7 +207,7 @@ getWmiInfo (int mode)
|
||||||
http://social.msdn.microsoft.com/forums/en-US/vcgeneral/thread/d6420012-e432-4964-8506-6f6b65e5a451
|
http://social.msdn.microsoft.com/forums/en-US/vcgeneral/thread/d6420012-e432-4964-8506-6f6b65e5a451
|
||||||
*/
|
*/
|
||||||
|
|
||||||
char buffer[128];
|
static char buffer[128];
|
||||||
HRESULT hres;
|
HRESULT hres;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
IWbemLocator *pLoc = NULL;
|
IWbemLocator *pLoc = NULL;
|
||||||
|
@ -216,27 +216,30 @@ getWmiInfo (int mode)
|
||||||
IWbemClassObject *pclsObj;
|
IWbemClassObject *pclsObj;
|
||||||
ULONG uReturn = 0;
|
ULONG uReturn = 0;
|
||||||
|
|
||||||
strcpy (buffer, "Unknown");
|
hres = CoInitializeEx (0, COINIT_APARTMENTTHREADED | COINIT_SPEED_OVER_MEMORY);
|
||||||
hres = CoInitializeEx (0, COINIT_MULTITHREADED);
|
|
||||||
|
|
||||||
if (FAILED (hres))
|
if (FAILED (hres))
|
||||||
{
|
{
|
||||||
|
strcpy (buffer, "Error Code 0");
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
hres = CoInitializeSecurity (NULL, -1, NULL, NULL, RPC_C_AUTHN_LEVEL_DEFAULT, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE, NULL);
|
hres = CoInitializeSecurity (NULL, -1, NULL, NULL, RPC_C_AUTHN_LEVEL_DEFAULT, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE, NULL);
|
||||||
|
|
||||||
if (FAILED (hres))
|
/* mysteriously failing after the first execution, but only when used as a plugin, skip it */
|
||||||
|
/*if (FAILED (hres))
|
||||||
{
|
{
|
||||||
CoUninitialize ();
|
CoUninitialize ();
|
||||||
|
strcpy (buffer, "Error Code 1");
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
hres = CoCreateInstance (CLSID_WbemLocator, 0, CLSCTX_INPROC_SERVER, IID_IWbemLocator, (LPVOID *) &pLoc);
|
hres = CoCreateInstance (CLSID_WbemLocator, 0, CLSCTX_INPROC_SERVER, IID_IWbemLocator, (LPVOID *) &pLoc);
|
||||||
|
|
||||||
if (FAILED (hres))
|
if (FAILED (hres))
|
||||||
{
|
{
|
||||||
CoUninitialize ();
|
CoUninitialize ();
|
||||||
|
strcpy (buffer, "Error Code 2");
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,6 +249,7 @@ getWmiInfo (int mode)
|
||||||
{
|
{
|
||||||
pLoc->Release ();
|
pLoc->Release ();
|
||||||
CoUninitialize ();
|
CoUninitialize ();
|
||||||
|
strcpy (buffer, "Error Code 3");
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -256,6 +260,7 @@ getWmiInfo (int mode)
|
||||||
pSvc->Release ();
|
pSvc->Release ();
|
||||||
pLoc->Release ();
|
pLoc->Release ();
|
||||||
CoUninitialize ();
|
CoUninitialize ();
|
||||||
|
strcpy (buffer, "Error Code 4");
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -273,6 +278,7 @@ getWmiInfo (int mode)
|
||||||
pSvc->Release ();
|
pSvc->Release ();
|
||||||
pLoc->Release ();
|
pLoc->Release ();
|
||||||
CoUninitialize ();
|
CoUninitialize ();
|
||||||
|
strcpy (buffer, "Error Code 5");
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -294,12 +300,11 @@ getWmiInfo (int mode)
|
||||||
pEnumerator->Release ();
|
pEnumerator->Release ();
|
||||||
pclsObj->Release ();
|
pclsObj->Release ();
|
||||||
CoUninitialize ();
|
CoUninitialize ();
|
||||||
|
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
printInfo()
|
printInfo (char *word[], char *word_eol[], void *user_data)
|
||||||
{
|
{
|
||||||
xchat_printf (ph, "OS:\t%s\n", getOsName ());
|
xchat_printf (ph, "OS:\t%s\n", getOsName ());
|
||||||
xchat_printf (ph, "CPU:\t%s (%s)\n", getWmiInfo (0), getCpuMhz ());
|
xchat_printf (ph, "CPU:\t%s (%s)\n", getWmiInfo (0), getCpuMhz ());
|
||||||
|
@ -319,7 +324,7 @@ xchat_plugin_init (xchat_plugin *plugin_handle, char **plugin_name, char **plugi
|
||||||
*plugin_desc = "Display info about your hardware and OS";
|
*plugin_desc = "Display info about your hardware and OS";
|
||||||
*plugin_version = "1.0";
|
*plugin_version = "1.0";
|
||||||
|
|
||||||
xchat_hook_command (ph, "WINSYS", XCHAT_PRI_NORM, printInfo, 0, 0);
|
xchat_hook_command (ph, "WINSYS", XCHAT_PRI_NORM, printInfo, NULL, NULL);
|
||||||
xchat_command (ph, "MENU -ietc\\download.png ADD \"Window/Display System Info\" \"WINSYS\"");
|
xchat_command (ph, "MENU -ietc\\download.png ADD \"Window/Display System Info\" \"WINSYS\"");
|
||||||
|
|
||||||
xchat_printf (ph, "%s plugin loaded\n", *plugin_name);
|
xchat_printf (ph, "%s plugin loaded\n", *plugin_name);
|
||||||
|
@ -327,6 +332,7 @@ xchat_plugin_init (xchat_plugin *plugin_handle, char **plugin_name, char **plugi
|
||||||
return 1; /* return 1 for success */
|
return 1; /* return 1 for success */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
xchat_plugin_deinit (void)
|
xchat_plugin_deinit (void)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue