rainmeter-studio/Plugins/PluginSysInfo/SysInfo.cpp

501 lines
14 KiB
C++
Raw Normal View History

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
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2009-02-10 18:37:48 +00:00
*/
#include <windows.h>
#include <Iphlpapi.h>
#include <Netlistmgr.h>
2012-03-17 13:36:02 +00:00
#include <stdio.h>
#include <stdlib.h>
#include "../API/RainmeterAPI.h"
#include "../../Library/Export.h"
#include"../../Common/Platform.h"
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_IDLE_TIME,
2012-03-17 13:36:02 +00:00
MEASURE_ADAPTER_DESCRIPTION,
MEASURE_NET_MASK,
MEASURE_IP_ADDRESS,
MEASURE_GATEWAY_ADDRESS,
MEASURE_HOST_NAME,
MEASURE_DOMAIN_NAME,
MEASURE_DNS_SERVER,
MEASURE_INTERNET_CONNECTIVITY,
MEASURE_LAN_CONNECTIVITY,
2012-03-17 13:36:02 +00:00
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
};
NLM_CONNECTIVITY GetNetworkConnectivity();
2012-03-17 13:36:02 +00:00
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
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
}
else if (_wcsicmp(L"IDLE_TIME", type) == 0)
{
measure->type = MEASURE_IDLE_TIME;
}
2012-03-17 13:36:02 +00:00
else if (_wcsicmp(L"ADAPTER_DESCRIPTION", type) == 0)
{
defaultData = 0;
2012-03-17 13:36:02 +00:00
measure->type = MEASURE_ADAPTER_DESCRIPTION;
}
else if (_wcsicmp(L"NET_MASK", type) == 0)
{
defaultData = 0;
2012-03-17 13:36:02 +00:00
measure->type = MEASURE_NET_MASK;
}
else if (_wcsicmp(L"IP_ADDRESS", type) == 0)
{
defaultData = 0;
2012-03-17 13:36:02 +00:00
measure->type = MEASURE_IP_ADDRESS;
}
else if (_wcsicmp(L"GATEWAY_ADDRESS", type) == 0)
{
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"INTERNET_CONNECTIVITY", type) == 0)
{
measure->type = MEASURE_INTERNET_CONNECTIVITY;
}
else if (_wcsicmp(L"LAN_CONNECTIVITY", type) == 0)
{
measure->type = MEASURE_LAN_CONNECTIVITY;
}
2012-03-17 13:36:02 +00:00
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);
}
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;
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
{
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:
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:
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:
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:
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 Platform::GetPlatformName();
2012-03-17 13:36:02 +00:00
case MEASURE_ADAPTER_DESCRIPTION:
if (ERROR_SUCCESS == GetAdaptersInfo((IP_ADAPTER_INFO*)tmpBuffer, &tmpBufferLen))
2009-02-10 18:37:48 +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:
if (NO_ERROR == GetIpAddrTable((PMIB_IPADDRTABLE)tmpBuffer, &tmpBufferLen, FALSE))
2009-02-10 18:37:48 +00:00
{
PMIB_IPADDRTABLE ipTable = (PMIB_IPADDRTABLE)tmpBuffer;
2012-03-17 13:36:02 +00:00
if (measure->data >= 1000)
{
measure->data = measure->data - 999;
2012-03-17 13:36:02 +00:00
for (UINT i = 0; i < ipTable->dwNumEntries; ++i)
{
2012-03-17 13:36:02 +00:00
if ((ipTable->table[i].wType) & MIB_IPADDR_DISCONNECTED) continue;
--measure->data;
if (measure->data == 0)
{
DWORD ip = ipTable->table[i].dwAddr;
wsprintf(sBuffer, L"%i.%i.%i.%i", ip % 256, (ip >> 8) % 256, (ip >> 16) % 256, (ip >> 24) % 256);
return sBuffer;
}
}
}
2013-12-23 19:44:42 +00:00
else if (measure->data < (int)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;
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:
if (NO_ERROR == GetIpAddrTable((PMIB_IPADDRTABLE)tmpBuffer, &tmpBufferLen, FALSE))
2009-02-10 18:37:48 +00:00
{
PMIB_IPADDRTABLE ipTable = (PMIB_IPADDRTABLE)tmpBuffer;
2013-12-23 19:44:42 +00:00
if (measure->data < (int)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;
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:
if (ERROR_SUCCESS == GetAdaptersInfo((IP_ADAPTER_INFO*)tmpBuffer, &tmpBufferLen))
2009-02-10 18:37:48 +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:
if (ERROR_SUCCESS == GetNetworkParams((PFIXED_INFO)tmpBuffer, &tmpBufferLen))
2009-02-10 18:37:48 +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:
if (ERROR_SUCCESS == GetNetworkParams((PFIXED_INFO)tmpBuffer, &tmpBufferLen))
2009-02-10 18:37:48 +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:
if (ERROR_SUCCESS == GetNetworkParams((PFIXED_INFO)tmpBuffer, &tmpBufferLen))
2009-02-10 18:37:48 +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
}
case MEASURE_IDLE_TIME:
{
LASTINPUTINFO idle = { sizeof(LASTINPUTINFO) };
GetLastInputInfo(&idle);
return (double)((GetTickCount() - idle.dwTime) / 1000);
}
case MEASURE_INTERNET_CONNECTIVITY:
{
const auto connectivity = GetNetworkConnectivity();
return (connectivity & NLM_CONNECTIVITY_IPV4_INTERNET ||
connectivity & NLM_CONNECTIVITY_IPV6_INTERNET) ? 1.0 : -1.0;
}
case MEASURE_LAN_CONNECTIVITY:
return GetNetworkConnectivity() != NLM_CONNECTIVITY_DISCONNECTED ? 1.0 : -1.0;
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-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
}
NLM_CONNECTIVITY GetNetworkConnectivity()
{
// This is initialized like this in case INetworkListManager is not available (i.e. on WinXP).
// In such cases, we simply assume that there is an internet connection.
NLM_CONNECTIVITY connectivity =
(NLM_CONNECTIVITY)((int)NLM_CONNECTIVITY_IPV4_INTERNET | (int)NLM_CONNECTIVITY_IPV4_LOCALNETWORK);
INetworkListManager* nlm;
HRESULT hr = CoCreateInstance(
CLSID_NetworkListManager, NULL, CLSCTX_INPROC_SERVER, __uuidof(INetworkListManager), (void**)&nlm);
if (SUCCEEDED(hr))
{
nlm->GetConnectivity(&connectivity);
nlm->Release();
}
return connectivity;
}