2009-02-10 18:37:48 +00:00
|
|
|
/*
|
|
|
|
Copyright (C) 2004 Kimmo Pekkola
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
2012-01-23 06:36:15 +00:00
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2009-02-10 18:37:48 +00:00
|
|
|
*/
|
|
|
|
|
2012-03-17 13:36:02 +00:00
|
|
|
#define WIN32_LEAN_AND_MEAN
|
2009-02-10 18:37:48 +00:00
|
|
|
#include <windows.h>
|
|
|
|
#include <Iphlpapi.h>
|
2012-03-17 13:36:02 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include "../API/RainmeterAPI.h"
|
|
|
|
#include "../../Library/Export.h"
|
2011-02-03 18:09:24 +00:00
|
|
|
#include "../../Library/DisableThreadLibraryCalls.h" // contains DllMain entry point
|
2011-01-30 09:31:41 +00:00
|
|
|
|
2011-03-29 19:21:57 +00:00
|
|
|
typedef struct
|
2009-04-11 00:04:19 +00:00
|
|
|
{
|
2012-03-17 13:36:02 +00:00
|
|
|
int count; // Number of monitors
|
|
|
|
HMONITOR m_Monitors[32]; // Monitor info
|
|
|
|
RECT m_MonitorRect[32]; // Monitor rect on virtual screen
|
|
|
|
MONITORINFO m_MonitorInfo[32]; // Monitor information
|
2009-04-11 00:04:19 +00:00
|
|
|
} MULTIMONITOR_INFO;
|
|
|
|
|
2012-03-17 13:36:02 +00:00
|
|
|
MULTIMONITOR_INFO m_Monitors = {0};
|
2009-04-11 00:04:19 +00:00
|
|
|
|
2012-03-17 13:36:02 +00:00
|
|
|
enum MeasureType
|
|
|
|
{
|
|
|
|
MEASURE_COMPUTER_NAME,
|
|
|
|
MEASURE_USER_NAME,
|
|
|
|
MEASURE_WORK_AREA,
|
|
|
|
MEASURE_SCREEN_SIZE,
|
|
|
|
MEASURE_RAS_STATUS,
|
|
|
|
MEASURE_OS_VERSION,
|
|
|
|
MEASURE_OS_BITS,
|
|
|
|
MEASURE_ADAPTER_DESCRIPTION,
|
|
|
|
MEASURE_NET_MASK,
|
|
|
|
MEASURE_IP_ADDRESS,
|
|
|
|
MEASURE_GATEWAY_ADDRESS,
|
|
|
|
MEASURE_HOST_NAME,
|
|
|
|
MEASURE_DOMAIN_NAME,
|
|
|
|
MEASURE_DNS_SERVER,
|
|
|
|
MEASURE_WORK_AREA_TOP,
|
|
|
|
MEASURE_WORK_AREA_LEFT,
|
|
|
|
MEASURE_WORK_AREA_WIDTH,
|
|
|
|
MEASURE_WORK_AREA_HEIGHT,
|
|
|
|
MEASURE_SCREEN_WIDTH,
|
|
|
|
MEASURE_SCREEN_HEIGHT,
|
|
|
|
MEASURE_NUM_MONITORS,
|
|
|
|
MEASURE_VIRTUAL_SCREEN_TOP,
|
|
|
|
MEASURE_VIRTUAL_SCREEN_LEFT,
|
|
|
|
MEASURE_VIRTUAL_SCREEN_WIDTH,
|
|
|
|
MEASURE_VIRTUAL_SCREEN_HEIGHT
|
|
|
|
};
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2012-03-17 13:36:02 +00:00
|
|
|
struct MeasureData
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2012-03-17 13:36:02 +00:00
|
|
|
MeasureType type;
|
|
|
|
int data;
|
|
|
|
|
|
|
|
MeasureData() : type(), data() {}
|
2009-02-10 18:37:48 +00:00
|
|
|
};
|
|
|
|
|
2012-03-17 13:36:02 +00:00
|
|
|
LPCWSTR GetPlatformName();
|
|
|
|
BOOL CALLBACK MyInfoEnumProc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData);
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2012-03-17 13:36:02 +00:00
|
|
|
bool g_Initialized = false;
|
|
|
|
|
|
|
|
PLUGIN_EXPORT void Initialize(void** data, void* rm)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2012-03-17 13:36:02 +00:00
|
|
|
MeasureData* measure = new MeasureData;
|
|
|
|
*data = measure;
|
|
|
|
|
|
|
|
if (!g_Initialized)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2012-03-17 13:36:02 +00:00
|
|
|
if (GetSystemMetrics(SM_CMONITORS) > 32)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2013-05-31 14:28:39 +00:00
|
|
|
LSLog(LOG_ERROR, nullptr, L"SysInfo.dll: Max amount of monitors supported is 32.");
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
|
2012-03-17 13:36:02 +00:00
|
|
|
m_Monitors.count = 0;
|
2013-05-31 14:28:39 +00:00
|
|
|
EnumDisplayMonitors(nullptr, nullptr, MyInfoEnumProc, (LPARAM)(&m_Monitors));
|
2012-03-17 13:36:02 +00:00
|
|
|
g_Initialized = true;
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-17 13:36:02 +00:00
|
|
|
PLUGIN_EXPORT void Reload(void* data, void* rm, double* maxValue)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2012-03-17 13:36:02 +00:00
|
|
|
MeasureData* measure = (MeasureData*)data;
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2012-03-17 13:42:22 +00:00
|
|
|
int defaultData = -1;
|
|
|
|
|
2012-03-17 13:36:02 +00:00
|
|
|
LPCTSTR type = RmReadString(rm, L"SysInfoType", L"");
|
|
|
|
if (_wcsicmp(L"COMPUTER_NAME", type) == 0)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2012-03-17 13:36:02 +00:00
|
|
|
measure->type = MEASURE_COMPUTER_NAME;
|
|
|
|
}
|
|
|
|
else if (_wcsicmp(L"USER_NAME", type) == 0)
|
|
|
|
{
|
|
|
|
measure->type = MEASURE_USER_NAME;
|
|
|
|
}
|
|
|
|
else if (_wcsicmp(L"WORK_AREA", type) == 0)
|
|
|
|
{
|
|
|
|
measure->type = MEASURE_WORK_AREA;
|
|
|
|
}
|
|
|
|
else if (_wcsicmp(L"SCREEN_SIZE", type) == 0)
|
|
|
|
{
|
|
|
|
measure->type = MEASURE_SCREEN_SIZE;
|
|
|
|
}
|
|
|
|
else if (_wcsicmp(L"RAS_STATUS", type) == 0)
|
|
|
|
{
|
|
|
|
measure->type = MEASURE_RAS_STATUS;
|
|
|
|
}
|
|
|
|
else if (_wcsicmp(L"OS_VERSION", type) == 0)
|
|
|
|
{
|
|
|
|
measure->type = MEASURE_OS_VERSION;
|
|
|
|
}
|
|
|
|
else if (_wcsicmp(L"OS_BITS", type) == 0)
|
|
|
|
{
|
|
|
|
measure->type = MEASURE_OS_BITS;
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
2012-03-17 13:36:02 +00:00
|
|
|
else if (_wcsicmp(L"ADAPTER_DESCRIPTION", type) == 0)
|
|
|
|
{
|
2012-03-17 13:42:22 +00:00
|
|
|
defaultData = 0;
|
2012-03-17 13:36:02 +00:00
|
|
|
measure->type = MEASURE_ADAPTER_DESCRIPTION;
|
|
|
|
}
|
|
|
|
else if (_wcsicmp(L"NET_MASK", type) == 0)
|
|
|
|
{
|
2012-03-17 13:42:22 +00:00
|
|
|
defaultData = 0;
|
2012-03-17 13:36:02 +00:00
|
|
|
measure->type = MEASURE_NET_MASK;
|
|
|
|
}
|
|
|
|
else if (_wcsicmp(L"IP_ADDRESS", type) == 0)
|
|
|
|
{
|
2012-03-17 13:42:22 +00:00
|
|
|
defaultData = 0;
|
2012-03-17 13:36:02 +00:00
|
|
|
measure->type = MEASURE_IP_ADDRESS;
|
|
|
|
}
|
|
|
|
else if (_wcsicmp(L"GATEWAY_ADDRESS", type) == 0)
|
|
|
|
{
|
2012-03-17 13:42:22 +00:00
|
|
|
defaultData = 0;
|
2012-03-17 13:36:02 +00:00
|
|
|
measure->type = MEASURE_GATEWAY_ADDRESS;
|
|
|
|
}
|
|
|
|
else if (_wcsicmp(L"HOST_NAME", type) == 0)
|
|
|
|
{
|
|
|
|
measure->type = MEASURE_HOST_NAME;
|
|
|
|
}
|
|
|
|
else if (_wcsicmp(L"DOMAIN_NAME", type) == 0)
|
|
|
|
{
|
|
|
|
measure->type = MEASURE_DOMAIN_NAME;
|
|
|
|
}
|
|
|
|
else if (_wcsicmp(L"DNS_SERVER", type) == 0)
|
|
|
|
{
|
|
|
|
measure->type = MEASURE_DNS_SERVER;
|
|
|
|
}
|
|
|
|
else if (_wcsicmp(L"WORK_AREA_TOP", type) == 0)
|
|
|
|
{
|
|
|
|
measure->type = MEASURE_WORK_AREA_TOP;
|
|
|
|
}
|
|
|
|
else if (_wcsicmp(L"WORK_AREA_LEFT", type) == 0)
|
|
|
|
{
|
|
|
|
measure->type = MEASURE_WORK_AREA_LEFT;
|
|
|
|
}
|
|
|
|
else if (_wcsicmp(L"WORK_AREA_WIDTH", type) == 0)
|
|
|
|
{
|
|
|
|
measure->type = MEASURE_WORK_AREA_WIDTH;
|
|
|
|
}
|
|
|
|
else if (_wcsicmp(L"WORK_AREA_HEIGHT", type) == 0)
|
|
|
|
{
|
|
|
|
measure->type = MEASURE_WORK_AREA_HEIGHT;
|
|
|
|
}
|
|
|
|
else if (_wcsicmp(L"SCREEN_WIDTH", type) == 0)
|
|
|
|
{
|
|
|
|
measure->type = MEASURE_SCREEN_WIDTH;
|
|
|
|
}
|
|
|
|
else if (_wcsicmp(L"SCREEN_HEIGHT", type) == 0)
|
|
|
|
{
|
|
|
|
measure->type = MEASURE_SCREEN_HEIGHT;
|
|
|
|
}
|
|
|
|
else if (_wcsicmp(L"NUM_MONITORS", type) == 0)
|
|
|
|
{
|
|
|
|
measure->type = MEASURE_NUM_MONITORS;
|
|
|
|
}
|
|
|
|
else if (_wcsicmp(L"VIRTUAL_SCREEN_TOP", type) == 0)
|
|
|
|
{
|
|
|
|
measure->type = MEASURE_VIRTUAL_SCREEN_TOP;
|
|
|
|
}
|
|
|
|
else if (_wcsicmp(L"VIRTUAL_SCREEN_LEFT", type) == 0)
|
|
|
|
{
|
|
|
|
measure->type = MEASURE_VIRTUAL_SCREEN_LEFT;
|
|
|
|
}
|
|
|
|
else if (_wcsicmp(L"VIRTUAL_SCREEN_WIDTH", type) == 0)
|
|
|
|
{
|
|
|
|
measure->type = MEASURE_VIRTUAL_SCREEN_WIDTH;
|
|
|
|
}
|
|
|
|
else if (_wcsicmp(L"VIRTUAL_SCREEN_HEIGHT", type) == 0)
|
|
|
|
{
|
|
|
|
measure->type = MEASURE_VIRTUAL_SCREEN_HEIGHT;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
WCHAR buffer[256];
|
|
|
|
_snwprintf_s(buffer, _TRUNCATE, L"SysInfo.dll: SysInfoType=%s is not valid in [%s]", type, RmGetMeasureName(rm));
|
|
|
|
RmLog(LOG_ERROR, buffer);
|
|
|
|
}
|
|
|
|
|
2012-03-17 13:42:22 +00:00
|
|
|
measure->data = RmReadInt(rm, L"SysInfoData", defaultData);
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
|
2012-03-17 13:36:02 +00:00
|
|
|
PLUGIN_EXPORT LPCWSTR GetString(void* data)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2012-03-17 13:36:02 +00:00
|
|
|
MeasureData* measure = (MeasureData*)data;
|
|
|
|
|
2012-03-20 13:13:35 +00:00
|
|
|
static WCHAR sBuffer[256];
|
|
|
|
DWORD sBufferLen = _countof(sBuffer);
|
|
|
|
|
|
|
|
BYTE tmpBuffer[7168];
|
|
|
|
ULONG tmpBufferLen = _countof(tmpBuffer);
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2012-03-17 13:36:02 +00:00
|
|
|
auto convertToWide = [&](LPCSTR str)->LPCWSTR
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2012-03-20 13:13:35 +00:00
|
|
|
MultiByteToWideChar(CP_ACP, 0, str, -1, sBuffer, 256);
|
|
|
|
return sBuffer;
|
2012-03-17 13:36:02 +00:00
|
|
|
};
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2012-03-17 13:36:02 +00:00
|
|
|
switch (measure->type)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2012-03-17 13:36:02 +00:00
|
|
|
case MEASURE_COMPUTER_NAME:
|
2012-03-20 13:13:35 +00:00
|
|
|
GetComputerName(sBuffer, &sBufferLen);
|
|
|
|
return sBuffer;
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2012-03-17 13:36:02 +00:00
|
|
|
case MEASURE_USER_NAME:
|
2012-03-20 13:13:35 +00:00
|
|
|
GetUserName(sBuffer, &sBufferLen);
|
|
|
|
return sBuffer;
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2012-03-17 13:36:02 +00:00
|
|
|
case MEASURE_WORK_AREA:
|
2012-03-20 13:13:35 +00:00
|
|
|
wsprintf(sBuffer, L"%i x %i", GetSystemMetrics(SM_CXFULLSCREEN), GetSystemMetrics(SM_CYFULLSCREEN));
|
|
|
|
return sBuffer;
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2012-03-17 13:36:02 +00:00
|
|
|
case MEASURE_SCREEN_SIZE:
|
2012-03-20 13:13:35 +00:00
|
|
|
wsprintf(sBuffer, L"%i x %i", GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
|
|
|
|
return sBuffer;
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2012-03-17 13:36:02 +00:00
|
|
|
case MEASURE_OS_VERSION:
|
|
|
|
return GetPlatformName();
|
2009-07-27 11:52:07 +00:00
|
|
|
|
2012-03-17 13:36:02 +00:00
|
|
|
case MEASURE_ADAPTER_DESCRIPTION:
|
2012-03-20 13:13:35 +00:00
|
|
|
if (ERROR_SUCCESS == GetAdaptersInfo((IP_ADAPTER_INFO*)tmpBuffer, &tmpBufferLen))
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2012-03-20 13:13:35 +00:00
|
|
|
PIP_ADAPTER_INFO info = (IP_ADAPTER_INFO*)tmpBuffer;
|
2009-02-10 18:37:48 +00:00
|
|
|
int i = 0;
|
|
|
|
while (info)
|
|
|
|
{
|
2012-03-17 13:36:02 +00:00
|
|
|
if (i == measure->data)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2012-03-17 13:36:02 +00:00
|
|
|
return convertToWide(info->Description);
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
2012-03-17 13:36:02 +00:00
|
|
|
|
2009-02-10 18:37:48 +00:00
|
|
|
info = info->Next;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2012-03-17 13:36:02 +00:00
|
|
|
case MEASURE_IP_ADDRESS:
|
2012-03-20 13:13:35 +00:00
|
|
|
if (NO_ERROR == GetIpAddrTable((PMIB_IPADDRTABLE)tmpBuffer, &tmpBufferLen, FALSE))
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2012-03-20 13:13:35 +00:00
|
|
|
PMIB_IPADDRTABLE ipTable = (PMIB_IPADDRTABLE)tmpBuffer;
|
2012-03-17 13:36:02 +00:00
|
|
|
if (measure->data >= 1000)
|
2009-04-13 05:45:08 +00:00
|
|
|
{
|
2012-03-17 13:42:22 +00:00
|
|
|
measure->data = measure->data - 999;
|
2012-03-17 13:36:02 +00:00
|
|
|
for (UINT i = 0; i < ipTable->dwNumEntries; ++i)
|
2009-04-13 05:45:08 +00:00
|
|
|
{
|
2012-03-17 13:36:02 +00:00
|
|
|
if ((ipTable->table[i].wType) & MIB_IPADDR_DISCONNECTED) continue;
|
|
|
|
--measure->data;
|
2012-03-17 13:42:22 +00:00
|
|
|
if (measure->data == 0)
|
2009-04-13 05:45:08 +00:00
|
|
|
{
|
|
|
|
DWORD ip = ipTable->table[i].dwAddr;
|
2012-03-20 13:13:35 +00:00
|
|
|
wsprintf(sBuffer, L"%i.%i.%i.%i", ip % 256, (ip >> 8) % 256, (ip >> 16) % 256, (ip >> 24) % 256);
|
|
|
|
return sBuffer;
|
2009-04-13 05:45:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-03-17 13:36:02 +00:00
|
|
|
else if (measure->data < ipTable->dwNumEntries)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2012-03-17 13:36:02 +00:00
|
|
|
DWORD ip = ipTable->table[measure->data].dwAddr;
|
2012-03-20 13:13:35 +00:00
|
|
|
wsprintf(sBuffer, L"%i.%i.%i.%i", ip % 256, (ip >> 8) % 256, (ip >> 16) % 256, (ip >> 24) % 256);
|
|
|
|
return sBuffer;
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
}
|
2012-03-17 13:36:02 +00:00
|
|
|
return L"";
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2012-03-17 13:36:02 +00:00
|
|
|
case MEASURE_NET_MASK:
|
2012-03-20 13:13:35 +00:00
|
|
|
if (NO_ERROR == GetIpAddrTable((PMIB_IPADDRTABLE)tmpBuffer, &tmpBufferLen, FALSE))
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2012-03-20 13:13:35 +00:00
|
|
|
PMIB_IPADDRTABLE ipTable = (PMIB_IPADDRTABLE)tmpBuffer;
|
2012-03-17 13:36:02 +00:00
|
|
|
if (measure->data < ipTable->dwNumEntries)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2012-03-17 13:36:02 +00:00
|
|
|
DWORD ip = ipTable->table[measure->data].dwMask;
|
2012-03-20 13:13:35 +00:00
|
|
|
wsprintf(sBuffer, L"%i.%i.%i.%i", ip % 256, (ip >> 8) % 256, (ip >> 16) % 256, (ip >> 24) % 256);
|
|
|
|
return sBuffer;
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2012-03-17 13:36:02 +00:00
|
|
|
case MEASURE_GATEWAY_ADDRESS:
|
2012-03-20 13:13:35 +00:00
|
|
|
if (ERROR_SUCCESS == GetAdaptersInfo((IP_ADAPTER_INFO*)tmpBuffer, &tmpBufferLen))
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2012-03-20 13:13:35 +00:00
|
|
|
PIP_ADAPTER_INFO info = (IP_ADAPTER_INFO*)tmpBuffer;
|
2009-02-10 18:37:48 +00:00
|
|
|
int i = 0;
|
|
|
|
while (info)
|
|
|
|
{
|
2012-03-17 13:36:02 +00:00
|
|
|
if (i == measure->data)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2012-03-17 13:36:02 +00:00
|
|
|
return convertToWide(info->GatewayList.IpAddress.String);
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
info = info->Next;
|
2012-03-17 13:36:02 +00:00
|
|
|
++i;
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2012-03-17 13:36:02 +00:00
|
|
|
case MEASURE_HOST_NAME:
|
2012-03-20 13:13:35 +00:00
|
|
|
if (ERROR_SUCCESS == GetNetworkParams((PFIXED_INFO)tmpBuffer, &tmpBufferLen))
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2012-03-20 13:13:35 +00:00
|
|
|
PFIXED_INFO info = (PFIXED_INFO)tmpBuffer;
|
2012-03-17 13:36:02 +00:00
|
|
|
return convertToWide(info->HostName);
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2012-03-17 13:36:02 +00:00
|
|
|
case MEASURE_DOMAIN_NAME:
|
2012-03-20 13:13:35 +00:00
|
|
|
if (ERROR_SUCCESS == GetNetworkParams((PFIXED_INFO)tmpBuffer, &tmpBufferLen))
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2012-03-20 13:13:35 +00:00
|
|
|
PFIXED_INFO info = (PFIXED_INFO)tmpBuffer;
|
2012-03-17 13:36:02 +00:00
|
|
|
return convertToWide(info->DomainName);
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2012-03-17 13:36:02 +00:00
|
|
|
case MEASURE_DNS_SERVER:
|
2012-03-20 13:13:35 +00:00
|
|
|
if (ERROR_SUCCESS == GetNetworkParams((PFIXED_INFO)tmpBuffer, &tmpBufferLen))
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2012-03-20 13:13:35 +00:00
|
|
|
PFIXED_INFO info = (PFIXED_INFO)tmpBuffer;
|
2009-02-10 18:37:48 +00:00
|
|
|
if (info->CurrentDnsServer)
|
|
|
|
{
|
2012-03-17 13:36:02 +00:00
|
|
|
return convertToWide(info->CurrentDnsServer->IpAddress.String);
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-03-17 13:36:02 +00:00
|
|
|
return convertToWide(info->DnsServerList.IpAddress.String);
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-05-31 14:28:39 +00:00
|
|
|
return nullptr;
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
|
2012-03-17 13:36:02 +00:00
|
|
|
PLUGIN_EXPORT double Update(void* data)
|
2009-04-11 00:04:19 +00:00
|
|
|
{
|
2012-03-17 13:36:02 +00:00
|
|
|
MeasureData* measure = (MeasureData*)data;
|
2009-04-11 00:04:19 +00:00
|
|
|
|
2012-03-17 13:36:02 +00:00
|
|
|
switch (measure->type)
|
2009-04-11 00:04:19 +00:00
|
|
|
{
|
2012-03-17 13:36:02 +00:00
|
|
|
case MEASURE_OS_BITS:
|
2009-04-11 00:04:19 +00:00
|
|
|
{
|
2012-03-17 13:36:02 +00:00
|
|
|
SYSTEM_INFO si = {0};
|
|
|
|
GetNativeSystemInfo(&si);
|
|
|
|
return (si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64 ||
|
|
|
|
si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_IA64) ? 64.0 : 32.0;
|
2009-04-11 00:04:19 +00:00
|
|
|
}
|
|
|
|
|
2012-03-17 13:36:02 +00:00
|
|
|
case MEASURE_WORK_AREA_WIDTH:
|
|
|
|
return (measure->data != -1)
|
|
|
|
? m_Monitors.m_MonitorInfo[measure->data - 1].rcWork.right - m_Monitors.m_MonitorInfo[measure->data - 1].rcWork.left
|
|
|
|
: GetSystemMetrics(SM_CXFULLSCREEN);
|
|
|
|
|
|
|
|
case MEASURE_WORK_AREA_HEIGHT:
|
|
|
|
return (measure->data != -1)
|
|
|
|
? m_Monitors.m_MonitorInfo[measure->data - 1].rcWork.bottom - m_Monitors.m_MonitorInfo[measure->data - 1].rcWork.top
|
|
|
|
: GetSystemMetrics(SM_CYFULLSCREEN);
|
|
|
|
|
|
|
|
case MEASURE_SCREEN_WIDTH:
|
|
|
|
return (measure->data != -1)
|
|
|
|
? m_Monitors.m_MonitorInfo[measure->data - 1].rcMonitor.right - m_Monitors.m_MonitorInfo[measure->data - 1].rcMonitor.left
|
|
|
|
: GetSystemMetrics(SM_CXSCREEN);
|
|
|
|
|
|
|
|
case MEASURE_SCREEN_HEIGHT:
|
|
|
|
return (measure->data != -1)
|
|
|
|
? m_Monitors.m_MonitorInfo[measure->data - 1].rcMonitor.bottom - m_Monitors.m_MonitorInfo[measure->data - 1].rcMonitor.top
|
|
|
|
: GetSystemMetrics(SM_CYSCREEN);
|
|
|
|
|
|
|
|
case MEASURE_VIRTUAL_SCREEN_WIDTH:
|
2009-04-11 00:04:19 +00:00
|
|
|
return GetSystemMetrics(SM_CXVIRTUALSCREEN);
|
2012-09-14 00:04:52 +00:00
|
|
|
|
2012-03-17 13:36:02 +00:00
|
|
|
case MEASURE_VIRTUAL_SCREEN_HEIGHT:
|
2009-04-11 00:04:19 +00:00
|
|
|
return GetSystemMetrics(SM_CYVIRTUALSCREEN);
|
|
|
|
|
2012-03-17 13:36:02 +00:00
|
|
|
case MEASURE_NUM_MONITORS:
|
|
|
|
return GetSystemMetrics(SM_CMONITORS);
|
2009-04-11 00:04:19 +00:00
|
|
|
|
2012-03-17 13:36:02 +00:00
|
|
|
case MEASURE_WORK_AREA_TOP:
|
|
|
|
return (measure->data != -1)
|
|
|
|
? m_Monitors.m_MonitorInfo[measure->data - 1].rcWork.top
|
|
|
|
: m_Monitors.m_MonitorInfo[0].rcWork.top;
|
|
|
|
|
|
|
|
case MEASURE_WORK_AREA_LEFT:
|
|
|
|
return (measure->data != -1)
|
|
|
|
? m_Monitors.m_MonitorInfo[measure->data - 1].rcWork.left
|
|
|
|
: m_Monitors.m_MonitorInfo[0].rcWork.left;
|
|
|
|
|
|
|
|
case MEASURE_VIRTUAL_SCREEN_TOP:
|
|
|
|
return (measure->data != -1)
|
|
|
|
? m_Monitors.m_MonitorInfo[measure->data - 1].rcMonitor.top
|
|
|
|
: GetSystemMetrics(SM_YVIRTUALSCREEN);
|
|
|
|
|
|
|
|
case MEASURE_VIRTUAL_SCREEN_LEFT:
|
|
|
|
return (measure->data != -1)
|
|
|
|
? m_Monitors.m_MonitorInfo[measure->data - 1].rcMonitor.left
|
|
|
|
: GetSystemMetrics(SM_XVIRTUALSCREEN);
|
2009-04-11 00:04:19 +00:00
|
|
|
}
|
|
|
|
|
2012-03-17 13:36:02 +00:00
|
|
|
return 0.0;
|
2009-04-11 00:04:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
BOOL CALLBACK MyInfoEnumProc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData)
|
|
|
|
{
|
2012-03-17 13:36:02 +00:00
|
|
|
MULTIMONITOR_INFO* m = (MULTIMONITOR_INFO*)dwData;
|
2009-04-11 00:04:19 +00:00
|
|
|
m->m_Monitors[m->count] = hMonitor;
|
2012-03-17 13:36:02 +00:00
|
|
|
memcpy(&(m->m_MonitorRect[m->count]), lprcMonitor, sizeof(RECT));
|
|
|
|
m->m_MonitorInfo[m->count].cbSize = sizeof(MONITORINFO);
|
|
|
|
GetMonitorInfo(hMonitor, &(m->m_MonitorInfo[m->count]));
|
|
|
|
++m->count;
|
2009-04-11 00:04:19 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-03-17 13:36:02 +00:00
|
|
|
PLUGIN_EXPORT void Finalize(void* data)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2012-03-17 13:36:02 +00:00
|
|
|
MeasureData* measure = (MeasureData*)data;
|
|
|
|
delete measure;
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
|
2012-03-17 13:36:02 +00:00
|
|
|
LPCWSTR GetPlatformName()
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2012-03-17 13:36:02 +00:00
|
|
|
OSVERSIONINFOEX osvi = {sizeof(OSVERSIONINFOEX)};
|
|
|
|
if (GetVersionEx((OSVERSIONINFO*)&osvi))
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2012-03-17 13:36:02 +00:00
|
|
|
if (osvi.dwMajorVersion == 5)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2012-03-17 13:36:02 +00:00
|
|
|
if (osvi.dwMinorVersion == 2)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2012-03-17 13:36:02 +00:00
|
|
|
return L"Windows 2003";
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
2012-03-17 13:36:02 +00:00
|
|
|
else if (osvi.dwMinorVersion == 1)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2012-03-17 13:36:02 +00:00
|
|
|
return L"Windows XP";
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
}
|
2009-07-27 11:52:07 +00:00
|
|
|
else
|
|
|
|
{
|
2012-09-14 00:04:52 +00:00
|
|
|
if (osvi.dwMinorVersion == 2 && osvi.wProductType == VER_NT_WORKSTATION)
|
|
|
|
{
|
|
|
|
return L"Windows 8";
|
|
|
|
}
|
|
|
|
else if (osvi.dwMinorVersion == 2 && osvi.wProductType != VER_NT_WORKSTATION)
|
|
|
|
{
|
|
|
|
return L"Windows Server 2012";
|
|
|
|
}
|
|
|
|
else if (osvi.dwMinorVersion == 1 && osvi.wProductType == VER_NT_WORKSTATION)
|
2009-07-27 11:52:07 +00:00
|
|
|
{
|
2012-03-17 13:36:02 +00:00
|
|
|
return L"Windows 7";
|
2009-07-27 11:52:07 +00:00
|
|
|
}
|
2012-03-17 13:36:02 +00:00
|
|
|
else if (osvi.dwMinorVersion == 1 && osvi.wProductType != VER_NT_WORKSTATION)
|
2009-07-27 11:52:07 +00:00
|
|
|
{
|
2012-03-17 13:36:02 +00:00
|
|
|
return L"Windows Server 2008 R2";
|
2009-07-27 11:52:07 +00:00
|
|
|
}
|
2012-03-17 13:36:02 +00:00
|
|
|
else if (osvi.dwMinorVersion == 0 && osvi.wProductType == VER_NT_WORKSTATION)
|
2009-07-27 11:52:07 +00:00
|
|
|
{
|
2012-03-17 13:36:02 +00:00
|
|
|
return L"Windows Vista";
|
2009-07-27 11:52:07 +00:00
|
|
|
}
|
2012-03-17 13:36:02 +00:00
|
|
|
else if (osvi.dwMinorVersion == 0 && osvi.wProductType != VER_NT_WORKSTATION)
|
2009-07-27 11:52:07 +00:00
|
|
|
{
|
2012-03-17 13:36:02 +00:00
|
|
|
return L"Windows Server 2008";
|
2009-07-27 11:52:07 +00:00
|
|
|
}
|
|
|
|
}
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
|
2012-03-17 13:36:02 +00:00
|
|
|
return L"Unknown";
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|