Exemple #1
0
CString common::FormatSystemTime(__time64_t time)
{
	SYSTEMTIME systime;

	FILETIME ftInstallTime = {0};
	if (Time2Filetime(time, &ftInstallTime))
	{
		FILETIME ftLocalInstallTime = {0};
		if (FileTimeToLocalFileTime(&ftInstallTime, &ftLocalInstallTime))
		{
			FileTimeToSystemTime(&ftLocalInstallTime, &systime);
		}
	}

	CString datetime;
	datetime.Format(_T("%04d-%02d-%02d %02d:%02d:%02d"), 
		systime.wYear, systime.wMonth, systime.wDay,
		systime.wHour, systime.wMinute, systime.wSecond);

	return datetime;
}
void ClientInfoManager::TransferInfo( LPCTSTR clientid, const CLIENT_BASE_INFO* pBaseInfo, CLIENT_INFO& info ) const
{
	ZeroMemory(&info, sizeof(CLIENT_INFO));
	_tcscpy_s(info.clientid, clientid);
	//ZeroMemory(&info.installTime, sizeof(info.installTime));
	if (NULL != pBaseInfo)
	{
		info.bX64 = pBaseInfo->bX64;
		_tcscpy_s(info.computerName, pBaseInfo->computerName.c_str());
		info.connectIP = pBaseInfo->connectIP;
		info.windowsVersion = pBaseInfo->windowsVersion;
		_tcscpy_s(info.mods, pBaseInfo->mods.c_str());
		_tcscpy_s(info.groups,pBaseInfo->groups.c_str());
		_tcscpy_s(info.priv,pBaseInfo->priv.c_str());
		_tcscpy_s(info.lang,pBaseInfo->lang.c_str());
		_tcscpy_s(info.vercode,pBaseInfo->vercode.c_str());
		info.cpufrep = pBaseInfo->cpufrep;
		info.memsize = pBaseInfo->memsize;
		info.cpunum = pBaseInfo->cpunum;

		switch (pBaseInfo->commtype)
		{
		case COMMNAME_HTTP:
			_tcscpy_s(info.proto,_T("HTTP"));
			break;
		case COMMNAME_HTTPS:
			_tcscpy_s(info.proto,_T("HTTPS"));
			break;
		case COMMNAME_TCP:
			_tcscpy_s(info.proto,_T("TCP"));
			break;
		case COMMNAME_TCPS:
			_tcscpy_s(info.proto,_T("TCPS"));
			break;
		case COMMNAME_UDP:
			_tcscpy_s(info.proto,_T("UDP"));
			break;
		case COMMNAME_UDPS:
			_tcscpy_s(info.proto,_T("UDPS"));
			break;
		default:
			break;
		}

		FILETIME ftInstallTime = {0};
		if (Time2Filetime(pBaseInfo->installTime, &ftInstallTime))
		{
			FILETIME ftLocalInstallTime = {0};
			if (FileTimeToLocalFileTime(&ftInstallTime, &ftLocalInstallTime))
			{
				FileTimeToSystemTime(&ftLocalInstallTime, &info.installTime);
			}
		}

		info.localIPCount = min(MAX_LOCALIP_COUNT, pBaseInfo->localIPList.size());
		for (USHORT i = 0; i < info.localIPCount; i++)
		{
			info.localIPList[i] = ::htonl(inet_addr(t2a(pBaseInfo->localIPList[i].c_str())));
		}
	}
	else
	{
		info.bX64 = FALSE;
		info.connectIP = 0;
		info.windowsVersion = WINDOWS_VERSION_NONE;
		info.localIPCount = 0;
	}
}