ReactOS 0.4.15-dev-7928-g68a8619
lanstatusui.cpp File Reference
#include "precomp.h"
#include <winsock.h>
Include dependency graph for lanstatusui.cpp:

Go to the source code of this file.

Macros

#define NETTIMERID   0xFABC
 

Functions

VOID UpdateLanStatusUiDlg (HWND hwndDlg, MIB_IFROW *IfEntry, LANSTATUSUI_CONTEXT *pContext)
 
VOID UpdateLanStatus (HWND hwndDlg, LANSTATUSUI_CONTEXT *pContext)
 
VOID InitializeLANStatusUiDlg (HWND hwndDlg, LANSTATUSUI_CONTEXT *pContext)
 
static VOID InsertColumnToListView (HWND hDlgCtrl, UINT ResId, UINT SubItem, UINT Size)
 
static VOID AddIPAddressToListView (HWND hDlgCtrl, PIP_ADDR_STRING pAddr, INT Index)
 
static INT InsertItemToListView (HWND hDlgCtrl, UINT ResId)
 
static BOOL tmToStr (IN struct tm *pTM, OUT LPWSTR szBuffer, IN UINT nBufferSize)
 
INT_PTR CALLBACK LANStatusUiDetailsDlg (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
INT_PTR CALLBACK LANStatusUiAdvancedDlg (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
VOID DisableNetworkAdapter (INetConnection *pNet, LANSTATUSUI_CONTEXT *pContext, HWND hwndDlg)
 
INT_PTR CALLBACK LANStatusUiDlg (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
VOID InitializePropertyDialog (LANSTATUSUI_CONTEXT *pContext, NETCON_PROPERTIES *pProperties)
 
static int CALLBACK PropSheetProc (HWND hwndDlg, UINT uMsg, LPARAM lParam)
 
VOID ShowStatusPropertyDialog (LANSTATUSUI_CONTEXT *pContext, HWND hwndDlg)
 
INT_PTR CALLBACK LANStatusDlg (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 

Macro Definition Documentation

◆ NETTIMERID

#define NETTIMERID   0xFABC

Definition at line 12 of file lanstatusui.cpp.

Function Documentation

◆ AddIPAddressToListView()

static VOID AddIPAddressToListView ( HWND  hDlgCtrl,
PIP_ADDR_STRING  pAddr,
INT  Index 
)
static

Definition at line 310 of file lanstatusui.cpp.

314{
315 LVITEMW li;
317 WCHAR szBuffer[100];
318 UINT SubIndex;
319
320 ZeroMemory(&li, sizeof(LVITEMW));
321 li.mask = LVIF_TEXT;
322 li.iItem = Index;
323 pCur = pAddr;
324 SubIndex = 0;
325
326 do
327 {
328 if (SubIndex)
329 {
330 ZeroMemory(&li, sizeof(LVITEMW));
331 li.mask = LVIF_TEXT;
332 li.iItem = Index;
333 li.iSubItem = 0;
334 li.pszText = (LPWSTR)L"";
335 li.iItem = SendMessageW(hDlgCtrl, LVM_INSERTITEMW, 0, (LPARAM)&li);
336 }
337
338 if (MultiByteToWideChar(CP_ACP, 0, pCur->IpAddress.String, -1, szBuffer, sizeof(szBuffer)/sizeof(WCHAR)))
339 {
340 li.pszText = szBuffer;
341 li.iSubItem = 1;
342 li.iItem = Index++;
343 SendMessageW(hDlgCtrl, LVM_SETITEMW, 0, (LPARAM)&li);
344 }
345 SubIndex++;
346 pCur = pCur->Next;
347 } while (pCur && pCur->IpAddress.String[0]);
348}
#define CP_ACP
Definition: compat.h:109
#define MultiByteToWideChar
Definition: compat.h:110
PWDF_CHILD_ADDRESS_DESCRIPTION_HEADER pAddr
SINGLE_LIST_ENTRY * pCur
LARGE_INTEGER li
Definition: fxtimerapi.cpp:235
unsigned int UINT
Definition: ndis.h:50
#define L(x)
Definition: ntvdm.h:50
#define LVM_SETITEMW
Definition: commctrl.h:2397
#define LVIF_TEXT
Definition: commctrl.h:2309
#define LVM_INSERTITEMW
Definition: commctrl.h:2404
struct _SINGLE_LIST_ENTRY * Next
Definition: ntbasedef.h:629
_In_ WDFCOLLECTION _In_ ULONG Index
#define ZeroMemory
Definition: winbase.h:1712
LONG_PTR LPARAM
Definition: windef.h:208
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by LANStatusUiDetailsDlg().

◆ DisableNetworkAdapter()

VOID DisableNetworkAdapter ( INetConnection pNet,
LANSTATUSUI_CONTEXT pContext,
HWND  hwndDlg 
)

Definition at line 628 of file lanstatusui.cpp.

629{
630 HRESULT hr = pNet->Disconnect();
632 return;
633
635
637 ZeroMemory(&nid, sizeof(nid));
638 nid.cbSize = sizeof(nid);
639 nid.uID = pContext->uID;
640 nid.hWnd = pContext->hwndDlg;
641 nid.uFlags = NIF_STATE;
642 nid.dwState = NIS_HIDDEN;
643 nid.dwStateMask = NIS_HIDDEN;
644
646}
#define FAILED_UNEXPECTEDLY(hr)
Definition: precomp.h:121
HRESULT Disconnect()
NOTIFYICONDATA nid
Definition: magnifier.c:44
#define PSBTN_CANCEL
Definition: prsht.h:151
#define PropSheet_PressButton(d, i)
Definition: prsht.h:348
#define NIM_MODIFY
Definition: shellapi.h:95
HRESULT hr
Definition: shlfolder.c:183
DWORD dwStateMask
Definition: shellapi.h:239
BOOL WINAPI Shell_NotifyIconW(DWORD dwMessage, PNOTIFYICONDATAW pnid)
Definition: systray.cpp:128
HWND WINAPI GetParent(_In_ HWND)

Referenced by LANStatusUiDlg().

◆ InitializeLANStatusUiDlg()

VOID InitializeLANStatusUiDlg ( HWND  hwndDlg,
LANSTATUSUI_CONTEXT pContext 
)

Definition at line 255 of file lanstatusui.cpp.

256{
257 WCHAR szBuffer[MAX_PATH] = {0};
258 NETCON_PROPERTIES * pProperties;
259
260 if (pContext->pNet->GetProperties(&pProperties) != S_OK)
261 return;
262
263 if (pProperties->Status == NCS_DISCONNECTED)
265 else if (pProperties->Status == NCS_MEDIA_DISCONNECTED)
267 else if (pProperties->Status == NCS_CONNECTING)
269 else if (pProperties->Status == NCS_CONNECTED)
271
272 SendDlgItemMessageW(hwndDlg, IDC_STATUS, WM_SETTEXT, 0, (LPARAM)szBuffer);
273
274 pContext->dwInOctets = 0;
275 pContext->dwOutOctets = 0;
276
277 /* update adapter info */
278 pContext->Status = -1;
279 UpdateLanStatus(hwndDlg, pContext);
280 NcFreeNetconProperties(pProperties);
281}
#define IDS_STATUS_CONNECTED
Definition: resource.h:85
#define IDC_STATUS
Definition: resource.h:41
#define IDS_STATUS_DISCONNECTED
Definition: resource.h:83
#define IDS_STATUS_UNREACHABLE
Definition: resource.h:82
#define IDS_STATUS_CONNECTING
Definition: resource.h:84
#define MAX_PATH
Definition: compat.h:34
HRESULT GetProperties([out] NETCON_PROPERTIES **ppProps)
#define S_OK
Definition: intsafe.h:52
VOID UpdateLanStatus(HWND hwndDlg, LANSTATUSUI_CONTEXT *pContext)
@ NCS_CONNECTING
Definition: netcon.h:40
@ NCS_MEDIA_DISCONNECTED
Definition: netcon.h:46
@ NCS_CONNECTED
Definition: netcon.h:41
@ NCS_DISCONNECTED
Definition: netcon.h:39
HINSTANCE netshell_hInstance
Definition: netshell.cpp:12
VOID WINAPI NcFreeNetconProperties(NETCON_PROPERTIES *pProps)
Definition: netshell.cpp:119
INetConnection * pNet
Definition: lanstatusui.h:19
NETCON_STATUS Status
Definition: netcon.h:86
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_SETTEXT
Definition: winuser.h:1617

Referenced by LANStatusUiDlg().

◆ InitializePropertyDialog()

VOID InitializePropertyDialog ( LANSTATUSUI_CONTEXT pContext,
NETCON_PROPERTIES pProperties 
)

Definition at line 701 of file lanstatusui.cpp.

704{
705 DWORD dwSize, dwAdapterIndex, dwResult;
706 LPOLESTR pStr;
707 IP_ADAPTER_INFO *pAdapterInfo, *pCurAdapter;
708
709 if (FAILED(StringFromCLSID((CLSID)pProperties->guidId, &pStr)))
710 {
711 return;
712 }
713
714 /* get the IfTable */
715 dwSize = 0;
716 dwResult = GetAdaptersInfo(NULL, &dwSize);
717 if (dwResult!= ERROR_BUFFER_OVERFLOW)
718 {
719 CoTaskMemFree(pStr);
720 return;
721 }
722
723 pAdapterInfo = static_cast<PIP_ADAPTER_INFO>(CoTaskMemAlloc(dwSize));
724 if (!pAdapterInfo)
725 {
726 CoTaskMemFree(pAdapterInfo);
727 CoTaskMemFree(pStr);
728 return;
729 }
730
731 if (GetAdaptersInfo(pAdapterInfo, &dwSize) != NO_ERROR)
732 {
733 CoTaskMemFree(pAdapterInfo);
734 CoTaskMemFree(pStr);
735 return;
736 }
737
738 if (!GetAdapterIndexFromNetCfgInstanceId(pAdapterInfo, pStr, &dwAdapterIndex))
739 {
740 CoTaskMemFree(pAdapterInfo);
741 CoTaskMemFree(pStr);
742 return;
743 }
744
745 pCurAdapter = pAdapterInfo;
746 while (pCurAdapter->Index != dwAdapterIndex)
747 pCurAdapter = pCurAdapter->Next;
748
749
750 pContext->IpAddress = inet_addr(pCurAdapter->IpAddressList.IpAddress.String);
751 pContext->SubnetMask = inet_addr(pCurAdapter->IpAddressList.IpMask.String);
752 pContext->Gateway = inet_addr(pCurAdapter->GatewayList.IpAddress.String);
753 pContext->DHCPEnabled = pCurAdapter->DhcpEnabled;
754 CoTaskMemFree(pStr);
755 CoTaskMemFree(pAdapterInfo);
756 pContext->dwAdapterIndex = dwAdapterIndex;
757}
BOOL GetAdapterIndexFromNetCfgInstanceId(PIP_ADAPTER_INFO pAdapterInfo, LPWSTR szNetCfg, PDWORD pIndex)
#define NO_ERROR
Definition: dderror.h:5
#define NULL
Definition: types.h:112
HRESULT WINAPI StringFromCLSID(REFCLSID id, LPOLESTR *idstr)
Definition: compobj.c:2412
unsigned long DWORD
Definition: ntddk_ex.h:95
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:426
#define FAILED(hr)
Definition: intsafe.h:51
DWORD WINAPI GetAdaptersInfo(PIP_ADAPTER_INFO pAdapterInfo, PULONG pOutBufLen)
#define inet_addr(cp)
Definition: inet.h:98
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
static LPOLESTR
Definition: stg_prop.c:27
char String[4 *4]
Definition: iptypes.h:42
IP_ADDR_STRING IpAddressList
Definition: iptypes.h:63
IP_ADDR_STRING GatewayList
Definition: iptypes.h:64
struct _IP_ADAPTER_INFO * Next
Definition: iptypes.h:53
UINT DhcpEnabled
Definition: iptypes.h:61
IP_ADDRESS_STRING IpAddress
Definition: iptypes.h:47
IP_MASK_STRING IpMask
Definition: iptypes.h:48
#define ERROR_BUFFER_OVERFLOW
Definition: winerror.h:185

Referenced by ShowStatusPropertyDialog().

◆ InsertColumnToListView()

static VOID InsertColumnToListView ( HWND  hDlgCtrl,
UINT  ResId,
UINT  SubItem,
UINT  Size 
)
static

Definition at line 285 of file lanstatusui.cpp.

290{
291 WCHAR szBuffer[200];
292 LVCOLUMNW lc;
293
294 if (!LoadStringW(netshell_hInstance, ResId, szBuffer, sizeof(szBuffer)/sizeof(WCHAR)))
295 return;
296
297 memset(&lc, 0, sizeof(LV_COLUMN) );
299 lc.iSubItem = SubItem;
300 lc.fmt = LVCFMT_FIXED_WIDTH;
301 lc.cx = Size;
302 lc.cchTextMax = wcslen(szBuffer);
303 lc.pszText = szBuffer;
304
305 (void)SendMessageW(hDlgCtrl, LVM_INSERTCOLUMNW, SubItem, (LPARAM)&lc);
306}
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define LVCF_WIDTH
Definition: commctrl.h:2587
#define LVM_INSERTCOLUMNW
Definition: commctrl.h:2632
#define LVCF_FMT
Definition: commctrl.h:2586
#define LVCF_SUBITEM
Definition: commctrl.h:2589
#define LVCF_TEXT
Definition: commctrl.h:2588
#define LV_COLUMN
Definition: commctrl.h:2547
#define memset(x, y, z)
Definition: compat.h:39
int cchTextMax
Definition: commctrl.h:2568
LPWSTR pszText
Definition: commctrl.h:2567
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533

Referenced by LANStatusUiDetailsDlg().

◆ InsertItemToListView()

static INT InsertItemToListView ( HWND  hDlgCtrl,
UINT  ResId 
)
static

Definition at line 352 of file lanstatusui.cpp.

355{
356 LVITEMW li;
357 WCHAR szBuffer[100];
358
359 ZeroMemory(&li, sizeof(LVITEMW));
360 li.mask = LVIF_TEXT;
361 li.iItem = ListView_GetItemCount(hDlgCtrl);
362 if (LoadStringW(netshell_hInstance, ResId, szBuffer, sizeof(szBuffer)/sizeof(WCHAR)))
363 {
364 li.pszText = szBuffer;
365 return (INT)SendMessageW(hDlgCtrl, LVM_INSERTITEMW, 0, (LPARAM)&li);
366 }
367 return -1;
368}
#define ListView_GetItemCount(hwnd)
Definition: commctrl.h:2307
int32_t INT
Definition: typedefs.h:58

Referenced by LANStatusUiDetailsDlg().

◆ LANStatusDlg()

INT_PTR CALLBACK LANStatusDlg ( HWND  hwndDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 831 of file lanstatusui.cpp.

836{
837 LANSTATUSUI_CONTEXT * pContext;
838
839 switch (uMsg)
840 {
841 case WM_INITDIALOG:
842 pContext = (LANSTATUSUI_CONTEXT *)lParam;
844 pContext->nIDEvent = SetTimer(hwndDlg, NETTIMERID, 1000, NULL);
845 return TRUE;
846 case WM_TIMER:
847 pContext = (LANSTATUSUI_CONTEXT*)GetWindowLongPtr(hwndDlg, DWLP_USER);
848 if (wParam == (WPARAM)pContext->nIDEvent)
849 {
850 UpdateLanStatus(pContext->hwndDlg, pContext);
851 }
852 break;
853 case WM_SHOWSTATUSDLG:
854 if (LOWORD(lParam) == WM_LBUTTONUP)
855 {
856 pContext = (LANSTATUSUI_CONTEXT*)GetWindowLongPtr(hwndDlg, DWLP_USER);
857 if (!pContext)
858 break;
859
860 if (pContext->hwndDlg)
861 {
862 ShowWindow(GetParent(pContext->hwndDlg), SW_SHOW);
864 }
865 else
866 {
867 ShowStatusPropertyDialog(pContext, hwndDlg);
868 }
869 break;
870 }
871 break;
872 }
873 return FALSE;
874}
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
VOID ShowStatusPropertyDialog(LANSTATUSUI_CONTEXT *pContext, HWND hwndDlg)
#define NETTIMERID
Definition: lanstatusui.cpp:12
#define WM_SHOWSTATUSDLG
Definition: lanstatusui.h:6
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define LOWORD(l)
Definition: pedump.c:82
#define GetWindowLongPtr
Definition: treelist.c:73
#define SetWindowLongPtr
Definition: treelist.c:70
UINT_PTR WPARAM
Definition: windef.h:207
#define DWLP_USER
Definition: winuser.h:872
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define WM_INITDIALOG
Definition: winuser.h:1739
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
#define WM_TIMER
Definition: winuser.h:1742
#define WM_LBUTTONUP
Definition: winuser.h:1777
#define SW_SHOW
Definition: winuser.h:775
BOOL WINAPI BringWindowToTop(_In_ HWND)

Referenced by CLanStatus::InitializeNetTaskbarNotifications().

◆ LANStatusUiAdvancedDlg()

INT_PTR CALLBACK LANStatusUiAdvancedDlg ( HWND  hwndDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 565 of file lanstatusui.cpp.

570{
571 WCHAR szBuffer[100] = {0};
573 LANSTATUSUI_CONTEXT * pContext;
574 DWORD dwIpAddr;
575
576
577 switch (uMsg)
578 {
579 case WM_INITDIALOG:
581 pContext = (LANSTATUSUI_CONTEXT*)page->lParam;
582 SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pContext);
583 if (pContext->DHCPEnabled)
584 LoadStringW(netshell_hInstance, IDS_ASSIGNED_DHCP, szBuffer, sizeof(szBuffer)/sizeof(WCHAR));
585 else
586 LoadStringW(netshell_hInstance, IDS_ASSIGNED_MANUAL, szBuffer, sizeof(szBuffer)/sizeof(WCHAR));
587
588 szBuffer[(sizeof(szBuffer)/sizeof(WCHAR))-1] = L'\0';
589 SendDlgItemMessageW(hwndDlg, IDC_DETAILSTYPE, WM_SETTEXT, 0, (LPARAM)szBuffer);
590
591
592 dwIpAddr = ntohl(pContext->IpAddress);
593 swprintf(szBuffer, L"%u.%u.%u.%u", FIRST_IPADDRESS(dwIpAddr), SECOND_IPADDRESS(dwIpAddr),
594 THIRD_IPADDRESS(dwIpAddr), FOURTH_IPADDRESS(dwIpAddr));
595 SendDlgItemMessageW(hwndDlg, IDC_DETAILSIP, WM_SETTEXT, 0, (LPARAM)szBuffer);
596
597 dwIpAddr = ntohl(pContext->SubnetMask);
598 swprintf(szBuffer, L"%u.%u.%u.%u", FIRST_IPADDRESS(dwIpAddr), SECOND_IPADDRESS(dwIpAddr),
599 THIRD_IPADDRESS(dwIpAddr), FOURTH_IPADDRESS(dwIpAddr));
601
602 dwIpAddr = ntohl(pContext->Gateway);
603 if (dwIpAddr)
604 {
605 swprintf(szBuffer, L"%u.%u.%u.%u", FIRST_IPADDRESS(dwIpAddr), SECOND_IPADDRESS(dwIpAddr),
606 THIRD_IPADDRESS(dwIpAddr), FOURTH_IPADDRESS(dwIpAddr));
608 }
609 return TRUE;
610 case WM_COMMAND:
611 if (LOWORD(wParam) == IDC_DETAILS)
612 {
613 pContext = (LANSTATUSUI_CONTEXT*)GetWindowLongPtr(hwndDlg, DWLP_USER);
614 if (pContext)
615 {
617 LANStatusUiDetailsDlg, (LPARAM)pContext);
618 }
619 }
620 break;
621 default:
622 break;
623 }
624 return FALSE;
625}
#define IDD_LAN_NETSTATUSDETAILS
Definition: resource.h:24
#define IDC_DETAILSTYPE
Definition: resource.h:46
#define IDC_DETAILSGATEWAY
Definition: resource.h:49
#define IDS_ASSIGNED_MANUAL
Definition: resource.h:104
#define IDC_DETAILSIP
Definition: resource.h:47
#define IDS_ASSIGNED_DHCP
Definition: resource.h:103
#define IDC_DETAILSSUBNET
Definition: resource.h:48
#define IDC_DETAILS
Definition: resource.h:50
#define swprintf
Definition: precomp.h:40
INT_PTR CALLBACK LANStatusUiDetailsDlg(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
#define ntohl(x)
Definition: module.h:205
#define PROPSHEETPAGE
Definition: prsht.h:389
#define FOURTH_IPADDRESS(x)
Definition: commctrl.h:4491
#define FIRST_IPADDRESS(x)
Definition: commctrl.h:4488
#define SECOND_IPADDRESS(x)
Definition: commctrl.h:4489
#define THIRD_IPADDRESS(x)
Definition: commctrl.h:4490
Definition: module.h:576
#define WM_COMMAND
Definition: winuser.h:1740
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
INT_PTR WINAPI DialogBoxParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)

Referenced by ShowStatusPropertyDialog().

◆ LANStatusUiDetailsDlg()

INT_PTR CALLBACK LANStatusUiDetailsDlg ( HWND  hwndDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 410 of file lanstatusui.cpp.

416{
417 LANSTATUSUI_CONTEXT * pContext;
418 LVITEMW li;
419 WCHAR szBuffer[100];
420 PIP_ADAPTER_INFO pAdapterInfo, pCurAdapter;
421 PIP_PER_ADAPTER_INFO pPerAdapter;
423 HWND hDlgCtrl;
424 RECT rect;
425
426 switch (uMsg)
427 {
428 case WM_INITDIALOG:
429 pContext = (LANSTATUSUI_CONTEXT*)lParam;
430
431 hDlgCtrl = GetDlgItem(hwndDlg, IDC_DETAILS);
432
433 /* get client rect */
434 GetClientRect(hDlgCtrl, &rect);
435
436 /* calculate column width */
437 dwSize = rect.right / 2;
438
441
442 dwSize = 0;
443 pCurAdapter = NULL;
444 pAdapterInfo = NULL;
446 {
447 pAdapterInfo = static_cast<PIP_ADAPTER_INFO>(CoTaskMemAlloc(dwSize));
448 if (pAdapterInfo)
449 {
450 if (GetAdaptersInfo(pAdapterInfo, &dwSize) == NO_ERROR)
451 {
452 pCurAdapter = pAdapterInfo;
453 while (pCurAdapter && pCurAdapter->Index != pContext->dwAdapterIndex)
454 pCurAdapter = pCurAdapter->Next;
455
456 if (pCurAdapter->Index != pContext->dwAdapterIndex)
457 pCurAdapter = NULL;
458 }
459 }
460 }
461
462 ZeroMemory(&li, sizeof(LVITEMW));
463 li.mask = LVIF_TEXT;
464 li.iSubItem = 1;
465 li.pszText = szBuffer;
466
467 if (pCurAdapter)
468 {
470 if (li.iItem >= 0)
471 {
472 swprintf(szBuffer, L"%02x-%02x-%02x-%02x-%02x-%02x",pCurAdapter->Address[0], pCurAdapter->Address[1],
473 pCurAdapter->Address[2], pCurAdapter->Address[3], pCurAdapter->Address[4], pCurAdapter->Address[5]);
474 SendMessageW(hDlgCtrl, LVM_SETITEMW, 0, (LPARAM)&li);
475 }
476 li.iItem = InsertItemToListView(hDlgCtrl, IDS_IP_ADDRESS);
477 if (li.iItem >= 0)
478 if (MultiByteToWideChar(CP_ACP, 0, pCurAdapter->IpAddressList.IpAddress.String, -1, szBuffer, sizeof(szBuffer)/sizeof(WCHAR)))
479 SendMessageW(hDlgCtrl, LVM_SETITEMW, 0, (LPARAM)&li);
480
481 li.iItem = InsertItemToListView(hDlgCtrl, IDS_SUBNET_MASK);
482 if (li.iItem >= 0)
483 if (MultiByteToWideChar(CP_ACP, 0, pCurAdapter->IpAddressList.IpMask.String, -1, szBuffer, sizeof(szBuffer)/sizeof(WCHAR)))
484 SendMessageW(hDlgCtrl, LVM_SETITEMW, 0, (LPARAM)&li);
485
486 li.iItem = InsertItemToListView(hDlgCtrl, IDS_DEF_GATEWAY);
487 if (li.iItem >= 0 && pCurAdapter->GatewayList.IpAddress.String[0] != '0')
488 {
489 if (MultiByteToWideChar(CP_ACP, 0, pCurAdapter->GatewayList.IpAddress.String, -1, szBuffer, sizeof(szBuffer)/sizeof(WCHAR)))
490 SendMessageW(hDlgCtrl, LVM_SETITEMW, 0, (LPARAM)&li);
491 }
492
493 li.iItem = InsertItemToListView(hDlgCtrl, IDS_DHCP_SERVER);
494 if (li.iItem >= 0 && pCurAdapter->DhcpServer.IpAddress.String[0] != '0')
495 {
496 if (MultiByteToWideChar(CP_ACP, 0, pCurAdapter->DhcpServer.IpAddress.String, -1, szBuffer, sizeof(szBuffer)/sizeof(WCHAR)))
497 SendMessageW(hDlgCtrl, LVM_SETITEMW, 0, (LPARAM)&li);
498 }
499
500 li.iItem = InsertItemToListView(hDlgCtrl, IDS_LEASE_OBTAINED);
501 if (li.iItem >= 0 && pCurAdapter->LeaseObtained != NULL)
502 {
503 struct tm *leaseOptained;
504
505 leaseOptained = localtime(&pCurAdapter->LeaseObtained);
506
507 if (tmToStr(leaseOptained, szBuffer, _countof(szBuffer)))
508 SendMessageW(hDlgCtrl, LVM_SETITEMW, 0, (LPARAM)&li);
509 }
510
511 li.iItem = InsertItemToListView(hDlgCtrl, IDS_LEASE_EXPIRES);
512 if (li.iItem >= 0 && pCurAdapter->LeaseExpires != NULL)
513 {
514 struct tm *leaseExpire;
515
516 leaseExpire = localtime(&pCurAdapter->LeaseExpires);
517
518 if (tmToStr(leaseExpire, szBuffer, _countof(szBuffer)))
519 SendMessageW(hDlgCtrl, LVM_SETITEMW, 0, (LPARAM)&li);
520 }
521 }
522
523 dwSize = 0;
524 li.iItem = InsertItemToListView(hDlgCtrl, IDS_DNS_SERVERS);
526 {
527 pPerAdapter = static_cast<PIP_PER_ADAPTER_INFO>(CoTaskMemAlloc(dwSize));
528 if (pPerAdapter)
529 {
530 if (GetPerAdapterInfo(pContext->dwAdapterIndex, pPerAdapter, &dwSize) == ERROR_SUCCESS)
531 {
532 if (li.iItem >= 0)
533 AddIPAddressToListView(hDlgCtrl, &pPerAdapter->DnsServerList, li.iItem);
534 }
535 CoTaskMemFree(pPerAdapter);
536 }
537 }
538
539 if (pCurAdapter)
540 {
541 li.iItem = InsertItemToListView(hDlgCtrl, IDS_WINS_SERVERS);
542 if (pCurAdapter->HaveWins)
543 {
544 AddIPAddressToListView(hDlgCtrl, &pCurAdapter->PrimaryWinsServer, li.iItem);
545 AddIPAddressToListView(hDlgCtrl, &pCurAdapter->SecondaryWinsServer, li.iItem+1);
546 }
547 }
548
549 CoTaskMemFree(pAdapterInfo);
550 break;
551
552 case WM_COMMAND:
553 if (LOWORD(wParam) == IDC_CLOSE)
554 {
555 EndDialog(hwndDlg, FALSE);
556 break;
557 }
558 }
559
560 return FALSE;
561}
#define ERROR_SUCCESS
Definition: deptool.c:10
#define IDS_VALUE
Definition: resource.h:26
#define IDS_DNS_SERVERS
Definition: resource.h:113
#define IDC_CLOSE
Definition: resource.h:52
#define IDS_DEF_GATEWAY
Definition: resource.h:109
#define IDS_IP_ADDRESS
Definition: resource.h:107
#define IDS_LEASE_EXPIRES
Definition: resource.h:112
#define IDS_DHCP_SERVER
Definition: resource.h:110
#define IDS_PHYSICAL_ADDRESS
Definition: resource.h:106
#define IDS_LEASE_OBTAINED
Definition: resource.h:111
#define IDS_SUBNET_MASK
Definition: resource.h:108
#define IDS_PROPERTY
Definition: resource.h:115
#define IDS_WINS_SERVERS
Definition: resource.h:114
DWORD WINAPI GetPerAdapterInfo(ULONG IfIndex, PIP_PER_ADAPTER_INFO pPerAdapterInfo, PULONG pOutBufLen)
static BOOL tmToStr(IN struct tm *pTM, OUT LPWSTR szBuffer, IN UINT nBufferSize)
static INT InsertItemToListView(HWND hDlgCtrl, UINT ResId)
static VOID AddIPAddressToListView(HWND hDlgCtrl, PIP_ADDR_STRING pAddr, INT Index)
static VOID InsertColumnToListView(HWND hDlgCtrl, UINT ResId, UINT SubItem, UINT Size)
_CRTIMP struct tm *__cdecl localtime(const time_t *_Time)
Definition: time.h:416
#define _countof(array)
Definition: sndvol32.h:68
& rect
Definition: startmenu.cpp:1413
IP_ADDR_STRING SecondaryWinsServer
Definition: iptypes.h:68
BYTE Address[MAX_ADAPTER_ADDRESS_LENGTH]
Definition: iptypes.h:58
IP_ADDR_STRING DhcpServer
Definition: iptypes.h:65
time_t LeaseObtained
Definition: iptypes.h:69
time_t LeaseExpires
Definition: iptypes.h:70
IP_ADDR_STRING PrimaryWinsServer
Definition: iptypes.h:67
IP_ADDR_STRING DnsServerList
Definition: iptypes.h:77
Definition: time.h:68
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)

Referenced by LANStatusUiAdvancedDlg().

◆ LANStatusUiDlg()

INT_PTR CALLBACK LANStatusUiDlg ( HWND  hwndDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 651 of file lanstatusui.cpp.

656{
658 LANSTATUSUI_CONTEXT * pContext;
659 LPPSHNOTIFY lppsn;
660
661 switch (uMsg)
662 {
663 case WM_INITDIALOG:
665 pContext = (LANSTATUSUI_CONTEXT*)page->lParam;
666 pContext->hwndDlg = hwndDlg;
667 InitializeLANStatusUiDlg(hwndDlg, pContext);
668 SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pContext);
669 return TRUE;
670 case WM_COMMAND:
671 pContext = (LANSTATUSUI_CONTEXT*)GetWindowLongPtr(hwndDlg, DWLP_USER);
673 {
674 if (pContext)
675 {
676 ShowNetConnectionProperties(pContext->pNet, GetParent(pContext->hwndDlg));
678 }
679 break;
680 }
681 else if (LOWORD(wParam) == IDC_ENDISABLE)
682 {
683 DisableNetworkAdapter(pContext->pNet, pContext, hwndDlg);
684 break;
685 }
686 case WM_NOTIFY:
687 lppsn = (LPPSHNOTIFY) lParam;
688 if (lppsn->hdr.code == PSN_APPLY || lppsn->hdr.code == PSN_RESET)
689 {
690 pContext = (LANSTATUSUI_CONTEXT*)GetWindowLongPtr(hwndDlg, DWLP_USER);
692 pContext->hwndDlg = NULL;
693 return TRUE;
694 }
695 break;
696 }
697 return FALSE;
698}
#define IDC_STATUS_PROPERTIES
Definition: resource.h:39
#define IDC_ENDISABLE
Definition: resource.h:40
VOID InitializeLANStatusUiDlg(HWND hwndDlg, LANSTATUSUI_CONTEXT *pContext)
VOID DisableNetworkAdapter(INetConnection *pNet, LANSTATUSUI_CONTEXT *pContext, HWND hwndDlg)
#define PSN_APPLY
Definition: prsht.h:117
#define PSNRET_NOERROR
Definition: prsht.h:129
#define PSN_RESET
Definition: prsht.h:118
struct _PSHNOTIFY * LPPSHNOTIFY
#define WM_NOTIFY
Definition: richedit.h:61
HRESULT ShowNetConnectionProperties(INetConnection *pNetConnect, HWND hwnd)
NMHDR hdr
Definition: prsht.h:330
UINT code
Definition: winuser.h:3159
#define DWLP_MSGRESULT
Definition: winuser.h:870

Referenced by ShowStatusPropertyDialog().

◆ PropSheetProc()

static int CALLBACK PropSheetProc ( HWND  hwndDlg,
UINT  uMsg,
LPARAM  lParam 
)
static

Definition at line 760 of file lanstatusui.cpp.

761{
762 // NOTE: This callback is needed to set large icon correctly.
763 HICON hIcon;
764 switch (uMsg)
765 {
766 case PSCB_INITIALIZED:
767 {
769 SendMessageW(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)hIcon);
770 break;
771 }
772 }
773 return 0;
774}
#define IDI_NET_IDLE
Definition: resource.h:10
static HICON
Definition: imagelist.c:84
HICON hIcon
Definition: msconfig.c:44
#define PSCB_INITIALIZED
Definition: prsht.h:75
#define ICON_BIG
Definition: tnclass.cpp:51
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE hInstance, _In_ LPCWSTR lpIconName)
Definition: cursoricon.c:2075

Referenced by ShowStatusPropertyDialog().

◆ ShowStatusPropertyDialog()

VOID ShowStatusPropertyDialog ( LANSTATUSUI_CONTEXT pContext,
HWND  hwndDlg 
)

Definition at line 777 of file lanstatusui.cpp.

780{
781 HPROPSHEETPAGE hppages[2];
782 PROPSHEETHEADERW pinfo;
783 NETCON_PROPERTIES * pProperties = NULL;
784
785 ZeroMemory(&pinfo, sizeof(PROPSHEETHEADERW));
786 ZeroMemory(hppages, sizeof(hppages));
787 pinfo.dwSize = sizeof(PROPSHEETHEADERW);
788 pinfo.dwFlags = PSH_NOCONTEXTHELP | PSH_PROPTITLE | PSH_NOAPPLYNOW |
790 pinfo.phpage = hppages;
791 pinfo.hwndParent = hwndDlg;
795
796 if (pContext->pNet->GetProperties(&pProperties) == S_OK)
797 {
798 if (pProperties->pszwName)
799 {
800 pinfo.pszCaption = pProperties->pszwName;
801 pinfo.dwFlags |= PSH_PROPTITLE;
802 }
803 InitializePropertyDialog(pContext, pProperties);
804 if (pProperties->MediaType == NCM_LAN && pProperties->Status == NCS_CONNECTED)
805 {
807 if (hppages[0])
808 pinfo.nPages++;
809
811 if (hppages[pinfo.nPages])
812 pinfo.nPages++;
813
814 if (pinfo.nPages)
815 {
816 PropertySheetW(&pinfo);
817 }
818 }
819 else if (pProperties->Status == NCS_MEDIA_DISCONNECTED || pProperties->Status == NCS_DISCONNECTED ||
820 pProperties->Status == NCS_HARDWARE_DISABLED)
821 {
822 ShowNetConnectionProperties(pContext->pNet, pContext->hwndDlg);
823 }
824
825 NcFreeNetconProperties(pProperties);
826 }
827}
#define IDD_LAN_NETSTATUS
Definition: resource.h:21
#define IDD_LAN_NETSTATUSADVANCED
Definition: resource.h:23
INT_PTR WINAPI PropertySheetW(LPCPROPSHEETHEADERW lppsh)
Definition: propsheet.c:2913
static int CALLBACK PropSheetProc(HWND hwndDlg, UINT uMsg, LPARAM lParam)
INT_PTR CALLBACK LANStatusUiAdvancedDlg(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
INT_PTR CALLBACK LANStatusUiDlg(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
VOID InitializePropertyDialog(LANSTATUSUI_CONTEXT *pContext, NETCON_PROPERTIES *pProperties)
struct _PSP * HPROPSHEETPAGE
Definition: mstask.idl:90
@ NCS_HARDWARE_DISABLED
Definition: netcon.h:44
@ NCM_LAN
Definition: netcon.h:71
HPROPSHEETPAGE InitializePropertySheetPage(LPWSTR resname, DLGPROC dlgproc, LPARAM lParam, LPWSTR szTitle)
Definition: netshell.cpp:29
#define PSH_PROPTITLE
Definition: prsht.h:40
#define PSH_USECALLBACK
Definition: prsht.h:48
#define PSH_USEICONID
Definition: prsht.h:42
struct _PROPSHEETHEADERW PROPSHEETHEADERW
#define PSH_NOAPPLYNOW
Definition: prsht.h:47
HINSTANCE hInstance
Definition: prsht.h:296
DWORD dwSize
Definition: prsht.h:293
DWORD dwFlags
Definition: prsht.h:294
LPCWSTR pszIcon
Definition: prsht.h:299
HWND hwndParent
Definition: prsht.h:295
PFNPROPSHEETCALLBACK pfnCallback
Definition: prsht.h:311
HPROPSHEETPAGE * phpage
Definition: prsht.h:309
LPCWSTR pszCaption
Definition: prsht.h:301
NETCON_MEDIATYPE MediaType
Definition: netcon.h:87

Referenced by LANStatusDlg().

◆ tmToStr()

static BOOL tmToStr ( IN struct tm pTM,
OUT LPWSTR  szBuffer,
IN UINT  nBufferSize 
)
static

Definition at line 372 of file lanstatusui.cpp.

376{
377 SYSTEMTIME st;
378 CString strBufferDate;
379 CString strBufferTime;
380 UINT nCharDate, nCharTime;
381 BOOL bResult = FALSE;
382
383 st.wYear = pTM->tm_year + 1900;
384 st.wMonth = pTM->tm_mon + 1;
385 st.wDay = pTM->tm_mday;
386 st.wHour = pTM->tm_hour;
387 st.wMinute = pTM->tm_min;
388 st.wSecond = pTM->tm_sec;
389
390 /* Check required size before cpy/cat */
391 nCharDate = GetDateFormatW(LOCALE_USER_DEFAULT, 0, &st, NULL, NULL, 0) + 1;
392 nCharTime = GetTimeFormatW(LOCALE_USER_DEFAULT, 0, &st, NULL, NULL, 0) + 1;
393
394 if (GetDateFormatW(LOCALE_USER_DEFAULT, 0, &st, NULL, strBufferDate.GetBuffer(nCharDate), nCharDate) &&
395 GetTimeFormatW(LOCALE_USER_DEFAULT, 0, &st, NULL, strBufferTime.GetBuffer(nCharTime), nCharTime))
396 {
397 StringCbCopy(szBuffer, nBufferSize, strBufferDate);
398 StringCbCat(szBuffer, nBufferSize, L" ");
399 StringCbCat(szBuffer, nBufferSize, strBufferTime);
400 bResult = TRUE;
401 }
402 strBufferDate.ReleaseBuffer();
403 strBufferTime.ReleaseBuffer();
404
405 return bResult;
406}
void ReleaseBuffer(_In_ int nNewLength=-1)
Definition: atlsimpstr.h:387
unsigned int BOOL
Definition: ntddk_ex.h:94
INT WINAPI GetTimeFormatW(LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCWSTR lpFormat, LPWSTR lpTimeStr, INT cchOut)
Definition: lcformat.c:1093
INT WINAPI GetDateFormatW(LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCWSTR lpFormat, LPWSTR lpDateStr, INT cchOut)
Definition: lcformat.c:993
#define LOCALE_USER_DEFAULT
#define StringCbCat
Definition: strsafe.h:334
#define StringCbCopy
Definition: strsafe.h:155
WORD wYear
Definition: winbase.h:905
WORD wMonth
Definition: winbase.h:906
WORD wHour
Definition: winbase.h:909
WORD wSecond
Definition: winbase.h:911
WORD wMinute
Definition: winbase.h:910
WORD wDay
Definition: winbase.h:908

Referenced by LANStatusUiDetailsDlg().

◆ UpdateLanStatus()

VOID UpdateLanStatus ( HWND  hwndDlg,
LANSTATUSUI_CONTEXT pContext 
)

Definition at line 121 of file lanstatusui.cpp.

122{
123 MIB_IFROW IfEntry;
124 HICON hIcon, hOldIcon = NULL;
126 NETCON_PROPERTIES * pProperties = NULL;
127
128 ZeroMemory(&IfEntry, sizeof(IfEntry));
129 IfEntry.dwIndex = pContext->dwAdapterIndex;
130 if (GetIfEntry(&IfEntry) != NO_ERROR)
131 {
132 return;
133 }
134
135 if (pContext->Status == (UINT)-1)
136 {
137 /*
138 * On first execution, pContext->dw[In|Out]Octets will be zero while
139 * the interface info is already refreshed with non-null data, so a
140 * gap is normal and does not correspond to an effective TX or RX packet.
141 */
142 pContext->dwInOctets = IfEntry.dwInOctets;
143 pContext->dwOutOctets = IfEntry.dwOutOctets;
144 }
145
146 hIcon = NULL;
148 {
149 if (pContext->dwInOctets == IfEntry.dwInOctets && pContext->dwOutOctets == IfEntry.dwOutOctets && pContext->Status != 0)
150 {
152 pContext->Status = 0;
153 }
154 else if (pContext->dwInOctets != IfEntry.dwInOctets && pContext->dwOutOctets != IfEntry.dwOutOctets && pContext->Status != 1)
155 {
157 pContext->Status = 1;
158 }
159 else if (pContext->dwInOctets != IfEntry.dwInOctets && pContext->Status != 2)
160 {
162 pContext->Status = 2;
163 }
164 else if (pContext->dwOutOctets != IfEntry.dwOutOctets && pContext->Status != 3)
165 {
167 pContext->Status = 3;
168 }
169 }
171 {
172 if (pContext->Status != 4)
173 {
175 pContext->Status = 4;
176 }
177 }
179 {
180 if (pContext->Status != 5)
181 {
183 pContext->Status = 5;
184 }
185 }
186
187 if (hwndDlg && hIcon)
188 {
189 hOldIcon = (HICON)SendDlgItemMessageW(hwndDlg, IDC_NETSTAT, STM_SETICON, (WPARAM)hIcon, 0);
190 if (hOldIcon)
191 DestroyIcon(hOldIcon);
192 }
193
194 ZeroMemory(&nid, sizeof(nid));
195 nid.cbSize = sizeof(nid);
196 nid.uID = pContext->uID;
197 nid.hWnd = pContext->hwndStatusDlg;
198 nid.uVersion = NOTIFYICON_VERSION;
199
200 if (pContext->pNet->GetProperties(&pProperties) == S_OK)
201 {
202 if (pProperties->dwCharacter & NCCF_SHOW_ICON)
203 {
204 if (hwndDlg)
206 else
207 nid.hIcon = hIcon;
208
209 if (nid.hIcon)
211
212 nid.uFlags |= NIF_STATE;
213 nid.dwState = 0;
214 nid.dwStateMask = NIS_HIDDEN;
215
216 if (pProperties->pszwName)
217 {
218 if (wcslen(pProperties->pszwName) * sizeof(WCHAR) < sizeof(nid.szTip))
219 {
220 nid.uFlags |= NIF_TIP;
221 wcscpy(nid.szTip, pProperties->pszwName);
222 }
223 else
224 {
225 CopyMemory(nid.szTip, pProperties->pszwName, sizeof(nid.szTip) - sizeof(WCHAR));
226 nid.szTip[(sizeof(nid.szTip)/sizeof(WCHAR))-1] = L'\0';
227 nid.uFlags |= NIF_TIP;
228 }
229 }
230 }
231 else
232 {
233 nid.uFlags |= NIF_STATE;
234 nid.dwState = NIS_HIDDEN;
235 nid.dwStateMask = NIS_HIDDEN;
236
237 }
238 NcFreeNetconProperties(pProperties);
239 }
240
242
243 if (nid.uFlags & NIF_ICON)
245
246 pContext->dwInOctets = IfEntry.dwInOctets;
247 pContext->dwOutOctets = IfEntry.dwOutOctets;
248
249 if (hwndDlg)
250 UpdateLanStatusUiDlg(hwndDlg, &IfEntry, pContext);
251}
#define IDI_NET_TRANSREC
Definition: resource.h:14
#define IDI_NET_TRANS
Definition: resource.h:13
#define IDI_NET_OFF
Definition: resource.h:11
#define IDI_NET_REC
Definition: resource.h:12
#define IDC_NETSTAT
Definition: resource.h:44
DWORD WINAPI GetIfEntry(PMIB_IFROW pIfRow)
#define MIB_IF_OPER_STATUS_DISCONNECTED
Definition: ipifcons.h:248
#define MIB_IF_OPER_STATUS_CONNECTED
Definition: ipifcons.h:250
#define MIB_IF_OPER_STATUS_NON_OPERATIONAL
Definition: ipifcons.h:246
#define MIB_IF_OPER_STATUS_UNREACHABLE
Definition: ipifcons.h:247
#define MIB_IF_OPER_STATUS_OPERATIONAL
Definition: ipifcons.h:251
VOID UpdateLanStatusUiDlg(HWND hwndDlg, MIB_IFROW *IfEntry, LANSTATUSUI_CONTEXT *pContext)
Definition: lanstatusui.cpp:21
@ NCCF_SHOW_ICON
Definition: netcon.h:20
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define NIF_ICON
Definition: shellapi.h:106
#define NIF_TIP
Definition: shellapi.h:107
DWORD dwInOctets
Definition: ifmib.h:47
INTERNAL_IF_OPER_STATUS dwOperStatus
Definition: ifmib.h:45
DWORD dwOutOctets
Definition: ifmib.h:53
DWORD dwIndex
Definition: ifmib.h:38
CHAR szTip[128]
Definition: shellapi.h:237
#define CopyMemory
Definition: winbase.h:1710
#define STM_SETICON
Definition: winuser.h:2092
#define IMAGE_ICON
Definition: winuser.h:212
#define LR_COPYFROMRESOURCE
Definition: winuser.h:1099
HANDLE WINAPI CopyImage(_In_ HANDLE, _In_ UINT, _In_ int, _In_ int, _In_ UINT)
Definition: cursoricon.c:1987
#define LR_SHARED
Definition: winuser.h:1100
#define LoadImage
Definition: winuser.h:5815
#define MAKEINTRESOURCE
Definition: winuser.h:591
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2053

Referenced by InitializeLANStatusUiDlg(), and LANStatusDlg().

◆ UpdateLanStatusUiDlg()

VOID UpdateLanStatusUiDlg ( HWND  hwndDlg,
MIB_IFROW IfEntry,
LANSTATUSUI_CONTEXT pContext 
)

Definition at line 21 of file lanstatusui.cpp.

25{
26 WCHAR szFormat[MAX_PATH] = {0};
27 WCHAR szBuffer[MAX_PATH] = {0};
28 SYSTEMTIME TimeConnected;
29 DWORD DurationSeconds;
30 WCHAR Buffer[100];
31 WCHAR DayBuffer[30];
32 WCHAR LocBuffer[50];
33
34#if 0
35 ULONGLONG Ticks;
36#else
37 DWORD Ticks;
38#endif
39
40 if (IfEntry->dwSpeed < 1000)
41 {
42 if (LoadStringW(netshell_hInstance, IDS_FORMAT_BIT, szFormat, sizeof(szFormat)/sizeof(WCHAR)))
43 {
44 swprintf(szBuffer, szFormat, IfEntry->dwSpeed);
45 SendDlgItemMessageW(hwndDlg, IDC_SPEED, WM_SETTEXT, 0, (LPARAM)szBuffer);
46 }
47 }
48 else if (IfEntry->dwSpeed < 1000000)
49 {
50 if (LoadStringW(netshell_hInstance, IDS_FORMAT_KBIT, szFormat, sizeof(szFormat)/sizeof(WCHAR)))
51 {
52 swprintf(szBuffer, szFormat, IfEntry->dwSpeed/1000);
53 SendDlgItemMessageW(hwndDlg, IDC_SPEED, WM_SETTEXT, 0, (LPARAM)szBuffer);
54 }
55 }
56 else if (IfEntry->dwSpeed < 1000000000)
57 {
58 if (LoadStringW(netshell_hInstance, IDS_FORMAT_MBIT, szFormat, sizeof(szFormat)/sizeof(WCHAR)))
59 {
60 swprintf(szBuffer, szFormat, IfEntry->dwSpeed/1000000);
61 SendDlgItemMessageW(hwndDlg, IDC_SPEED, WM_SETTEXT, 0, (LPARAM)szBuffer);
62 }
63 }
64 else
65 {
66 if (LoadStringW(netshell_hInstance, IDS_FORMAT_GBIT, szFormat, sizeof(szFormat)/sizeof(WCHAR)))
67 {
68 swprintf(szBuffer, szFormat, IfEntry->dwSpeed/1000000000);
69 SendDlgItemMessageW(hwndDlg, IDC_SPEED, WM_SETTEXT, 0, (LPARAM)szBuffer);
70 }
71 }
72
73 if (StrFormatByteSizeW(IfEntry->dwInOctets, szBuffer, sizeof(szFormat)/sizeof(WCHAR)))
74 {
75 SendDlgItemMessageW(hwndDlg, IDC_RECEIVED, WM_SETTEXT, 0, (LPARAM)szBuffer);
76 }
77
78 if (StrFormatByteSizeW(IfEntry->dwOutOctets, szBuffer, sizeof(szFormat)/sizeof(WCHAR)))
79 {
80 SendDlgItemMessageW(hwndDlg, IDC_SEND, WM_SETTEXT, 0, (LPARAM)szBuffer);
81 }
82
83#if 0
84 Ticks = GetTickCount64();
85#else
86 Ticks = GetTickCount();
87#endif
88
89 DurationSeconds = Ticks / 1000;
90 TimeConnected.wSecond = (DurationSeconds % 60);
91 TimeConnected.wMinute = (DurationSeconds / 60) % 60;
92 TimeConnected.wHour = (DurationSeconds / (60 * 60)) % 24;
93 TimeConnected.wDay = DurationSeconds / (60 * 60 * 24);
94
95 if (!GetTimeFormatW(LOCALE_USER_DEFAULT, 0, &TimeConnected, L"HH':'mm':'ss", LocBuffer, sizeof(LocBuffer) / sizeof(LocBuffer[0])))
96 return;
97
98 if (!TimeConnected.wDay)
99 {
100 SendDlgItemMessageW(hwndDlg, IDC_DURATION, WM_SETTEXT, 0, (LPARAM)LocBuffer);
101 }
102 else
103 {
104 if (TimeConnected.wDay == 1)
105 {
106 if (!LoadStringW(netshell_hInstance, IDS_DURATION_DAY, DayBuffer, sizeof(DayBuffer) / sizeof(DayBuffer[0])))
107 DayBuffer[0] = L'\0';
108 }
109 else
110 {
111 if (!LoadStringW(netshell_hInstance, IDS_DURATION_DAYS, DayBuffer, sizeof(DayBuffer) / sizeof(DayBuffer[0])))
112 DayBuffer[0] = L'\0';
113 }
114 swprintf(Buffer, DayBuffer, TimeConnected.wDay, LocBuffer);
116 }
117
118}
ULONGLONG WINAPI GetTickCount64(VOID)
Definition: GetTickCount64.c:9
Definition: bufpool.h:45
#define IDC_SPEED
Definition: resource.h:43
#define IDC_DURATION
Definition: resource.h:42
#define IDS_FORMAT_BIT
Definition: resource.h:97
#define IDS_DURATION_DAY
Definition: resource.h:101
#define IDS_DURATION_DAYS
Definition: resource.h:102
#define IDC_SEND
Definition: resource.h:37
#define IDS_FORMAT_KBIT
Definition: resource.h:99
#define IDC_RECEIVED
Definition: resource.h:38
#define IDS_FORMAT_MBIT
Definition: resource.h:98
#define IDS_FORMAT_GBIT
Definition: resource.h:100
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:455
LPWSTR WINAPI StrFormatByteSizeW(LONGLONG llBytes, LPWSTR lpszDest, UINT cchMax)
Definition: string.c:2388
DWORD dwSpeed
Definition: ifmib.h:41
uint64_t ULONGLONG
Definition: typedefs.h:67

Referenced by UpdateLanStatus().