Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NETSHELL] Remove erroneous DNS Server line and fix date/time format #2655

Merged
merged 1 commit into from Apr 28, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
42 changes: 39 additions & 3 deletions dll/shellext/netshell/lanstatusui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,43 @@ InsertItemToListView(
return -1;
}

static
BOOL
tmToStr(
IN struct tm *pTM,
OUT LPWSTR szBuffer,
IN UINT nBufferSize)
{
SYSTEMTIME st;
CString strBufferDate;
CString strBufferTime;
UINT nCharDate, nCharTime;
BOOL bResult = FALSE;

st.wYear = pTM->tm_year + 1900;
st.wMonth = pTM->tm_mon + 1;
st.wDay = pTM->tm_mday;
st.wHour = pTM->tm_hour;
st.wMinute = pTM->tm_min;
st.wSecond = pTM->tm_sec;

/* Check required size before cpy/cat */
nCharDate = GetDateFormatW(LOCALE_USER_DEFAULT, 0, &st, NULL, NULL, 0) + 1;
nCharTime = GetTimeFormatW(LOCALE_USER_DEFAULT, 0, &st, NULL, NULL, 0) + 1;

if (GetDateFormatW(LOCALE_USER_DEFAULT, 0, &st, NULL, strBufferDate.GetBuffer(nCharDate), nCharDate) &&
GetTimeFormatW(LOCALE_USER_DEFAULT, 0, &st, NULL, strBufferTime.GetBuffer(nCharTime), nCharTime))
{
StringCbCopy(szBuffer, nBufferSize, strBufferDate);
StringCbCat(szBuffer, nBufferSize, L" ");
StringCbCat(szBuffer, nBufferSize, strBufferTime);
bResult = TRUE;
}
strBufferDate.ReleaseBuffer();
strBufferTime.ReleaseBuffer();

return bResult;
}

INT_PTR
CALLBACK
Expand Down Expand Up @@ -454,7 +491,7 @@ LANStatusUiDetailsDlg(

leaseOptained = localtime(&pCurAdapter->LeaseObtained);

if (wcsftime(szBuffer, 100, L"%m/%d/%Y %H:%M:%S %p", leaseOptained) != 0)
if (tmToStr(leaseOptained, szBuffer, _countof(szBuffer)))
SendMessageW(hDlgCtrl, LVM_SETITEMW, 0, (LPARAM)&li);
}

Expand All @@ -465,7 +502,7 @@ LANStatusUiDetailsDlg(

leaseExpire = localtime(&pCurAdapter->LeaseExpires);

if (wcsftime(szBuffer, 100, L"%m/%d/%Y %H:%M:%S %p", leaseExpire) != 0)
if (tmToStr(leaseExpire, szBuffer, _countof(szBuffer)))
SendMessageW(hDlgCtrl, LVM_SETITEMW, 0, (LPARAM)&li);
}
}
Expand All @@ -479,7 +516,6 @@ LANStatusUiDetailsDlg(
{
if (GetPerAdapterInfo(pContext->dwAdapterIndex, pPerAdapter, &dwSize) == ERROR_SUCCESS)
{
li.iItem = InsertItemToListView(hDlgCtrl, IDS_DNS_SERVERS);
This conversation was marked as resolved.
Show resolved Hide resolved
if (li.iItem >= 0)
AddIPAddressToListView(hDlgCtrl, &pPerAdapter->DnsServerList, li.iItem);
}
Expand Down