ReactOS 0.4.15-dev-7924-g5949c20
SHDisconnectNetDrives.c File Reference
#include "netplwiz.h"
#include <wine/debug.h>
Include dependency graph for SHDisconnectNetDrives.c:

Go to the source code of this file.

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (netplwiz)
 
VOID InitializeListView (HWND hDlg)
 
VOID EnumerateConnectedDrives (HWND hDlg)
 
VOID UpdateButtonStatus (WPARAM wParam, LPARAM lParam, HWND hDlg)
 
DWORD DisconnectDriveExit (HWND hDlg)
 
static INT_PTR CALLBACK DisconnectDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
HRESULT WINAPI SHDisconnectNetDrives (PVOID Unused)
 

Variables

HINSTANCE hInstance
 

Function Documentation

◆ DisconnectDlgProc()

static INT_PTR CALLBACK DisconnectDlgProc ( HWND  hDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 155 of file SHDisconnectNetDrives.c.

156{
158 switch (uMsg)
159 {
160 case WM_INITDIALOG:
163 SendMessageW(hDlg, WM_SETICON, ICON_BIG, (LPARAM)hIcon);
164 SendMessageW(hDlg, WM_SETICON, ICON_SMALL, (LPARAM)hIconSm);
166 InitializeListView(hDlg);
168 return TRUE;
169
170 case WM_COMMAND:
171 switch (LOWORD(wParam))
172 {
173 case ID_OK:
175 break;
176 case IDCANCEL:
177 EndDialog(hDlg, IDCANCEL);
178 break;
179 }
180 break;
181
182 case WM_NOTIFY:
184 break;
185
186 default:
187 return FALSE;
188 }
189
190 return TRUE;
191}
VOID InitializeListView(HWND hDlg)
VOID UpdateButtonStatus(WPARAM wParam, LPARAM lParam, HWND hDlg)
VOID EnumerateConnectedDrives(HWND hDlg)
HINSTANCE hInstance
DWORD DisconnectDriveExit(HWND hDlg)
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define ID_OK
Definition: resource.h:9
#define IDI_DISCONNECT_NET_DRIVES
Definition: resource.h:15
static HICON
Definition: imagelist.c:84
HICON hIcon
Definition: msconfig.c:44
HICON hIconSm
Definition: msconfig.c:44
#define LOWORD(l)
Definition: pedump.c:82
#define WM_NOTIFY
Definition: richedit.h:61
#define ICON_BIG
Definition: tnclass.cpp:51
#define ICON_SMALL
Definition: tnclass.cpp:48
LONG_PTR LPARAM
Definition: windef.h:208
#define IDCANCEL
Definition: winuser.h:831
#define IMAGE_ICON
Definition: winuser.h:212
#define LR_COPYFROMRESOURCE
Definition: winuser.h:1099
#define WM_COMMAND
Definition: winuser.h:1740
HANDLE WINAPI LoadImageW(_In_opt_ HINSTANCE hInst, _In_ LPCWSTR name, _In_ UINT type, _In_ int cx, _In_ int cy, _In_ UINT fuLoad)
Definition: cursoricon.c:2203
#define SM_CYSMICON
Definition: winuser.h:1013
#define WM_INITDIALOG
Definition: winuser.h:1739
HANDLE WINAPI CopyImage(_In_ HANDLE, _In_ UINT, _In_ int, _In_ int, _In_ UINT)
Definition: cursoricon.c:1987
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define SM_CXSMICON
Definition: winuser.h:1012
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define LR_SHARED
Definition: winuser.h:1100
#define LR_DEFAULTSIZE
Definition: winuser.h:1094
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
int WINAPI GetSystemMetrics(_In_ int)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)

Referenced by SHDisconnectNetDrives().

◆ DisconnectDriveExit()

DWORD DisconnectDriveExit ( HWND  hDlg)

Definition at line 138 of file SHDisconnectNetDrives.c.

139{
140 TCHAR driveLetter[10];
141 HRESULT hr;
142 HWND hListView = GetDlgItem(hDlg, IDC_CONNECTEDDRIVELIST);
143 INT nItem = ListView_GetNextItem(hListView, -1, LVNI_SELECTED);
144
145 if (nItem == -1)
146 return 0;
147
148 ListView_GetItemText(hListView, nItem, 0, driveLetter, _countof(driveLetter));
150
151 EndDialog(hDlg, ID_OK);
152 return hr;
153}
#define IDC_CONNECTEDDRIVELIST
Definition: resource.h:8
#define LVNI_SELECTED
Definition: commctrl.h:2424
#define ListView_GetItemText(hwndLV, i, iSubItem_, pszText_, cchTextMax_)
Definition: commctrl.h:2684
#define ListView_GetNextItem(hwnd, i, flags)
Definition: commctrl.h:2434
HRESULT hr
Definition: shlfolder.c:183
#define _countof(array)
Definition: sndvol32.h:68
int32_t INT
Definition: typedefs.h:58
#define CONNECT_UPDATE_PROFILE
Definition: winnetwk.h:87
#define WNetCancelConnection2
Definition: winnetwk.h:607
char TCHAR
Definition: xmlstorage.h:189

Referenced by DisconnectDlgProc().

◆ EnumerateConnectedDrives()

VOID EnumerateConnectedDrives ( HWND  hDlg)

Definition at line 38 of file SHDisconnectNetDrives.c.

39{
41 HIMAGELIST hImgList;
42 HICON hIconDrive = NULL;
44 HWND hListView = GetDlgItem(hDlg, IDC_CONNECTEDDRIVELIST);
45
46 DWORD dRet;
47 HANDLE hEnum;
48 LPNETRESOURCE lpRes;
49 DWORD dwSize = 0x1000;
50 DWORD dwCount = -1;
51 LPNETRESOURCE lpCur;
52
53 /* List View Icons */
54 hShell32 = GetModuleHandleW(L"shell32.dll");
55 if (hShell32 == NULL)
56 return;
57
61 if (hIconDrive == NULL)
62 return;
63
64 hImgList = ImageList_Create(16, 16, ILC_COLOR32 | ILC_MASK, 1, 1);
65 if (hImgList == NULL)
66 {
67 DestroyIcon(hIconDrive);
68 return;
69 }
70
71 ImageList_AddIcon(hImgList, hIconDrive);
72 DestroyIcon(hIconDrive);
73 ListView_SetImageList(hListView, hImgList, LVSIL_SMALL);
74
76 if (dRet != WN_SUCCESS)
77 {
78 return;
79 }
80
81 lpRes = HeapAlloc(GetProcessHeap(), 0, dwSize);
82 if (!lpRes)
83 {
84 WNetCloseEnum(hEnum);
85 return;
86 }
87
88 do
89 {
90 ZeroMemory(lpRes, dwSize);
91 dRet = WNetEnumResource(hEnum, &dwCount, lpRes, &dwSize);
92 if (dRet == WN_SUCCESS || dRet == WN_MORE_DATA)
93 {
94 lpCur = lpRes;
95 for (; dwCount; dwCount--)
96 {
97 ZeroMemory(&item, sizeof(item));
98 item.mask = LVIF_TEXT | LVIF_IMAGE;
99 item.iImage = 0;
100 item.pszText = lpCur->lpLocalName;
101 item.lParam = 0;
102 item.iItem = ListView_InsertItem(hListView, &item);
103 ListView_SetItemText(hListView, item.iItem, 1, lpCur->lpRemoteName);
104 lpCur++;
105 }
106 }
107 } while (dRet != WN_NO_MORE_ENTRIES);
108
109 HeapFree(GetProcessHeap(), 0, lpRes);
110 WNetCloseEnum(hEnum);
111}
#define NULL
Definition: types.h:112
HIMAGELIST WINAPI ImageList_Create(INT cx, INT cy, UINT flags, INT cInitial, INT cGrow)
Definition: imagelist.c:804
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
unsigned long DWORD
Definition: ntddk_ex.h:95
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
static HMODULE hShell32
Definition: string.c:34
static ATOM item
Definition: dde.c:856
#define L(x)
Definition: ntvdm.h:50
#define LVSIL_SMALL
Definition: commctrl.h:2299
#define ListView_InsertItem(hwnd, pitem)
Definition: commctrl.h:2408
#define ListView_SetImageList(hwnd, himl, iImageList)
Definition: commctrl.h:2304
#define ILC_COLOR32
Definition: commctrl.h:358
#define LV_ITEM
Definition: commctrl.h:2337
#define ListView_SetItemText(hwndLV, i, iSubItem_, pszText_)
Definition: commctrl.h:2691
#define LVIF_TEXT
Definition: commctrl.h:2309
#define ImageList_AddIcon(himl, hicon)
Definition: commctrl.h:415
#define ILC_MASK
Definition: commctrl.h:351
#define LVIF_IMAGE
Definition: commctrl.h:2310
LPSTR lpLocalName
Definition: winnetwk.h:171
LPSTR lpRemoteName
Definition: winnetwk.h:172
#define ZeroMemory
Definition: winbase.h:1712
#define RESOURCE_CONNECTED
Definition: winnetwk.h:58
#define RESOURCETYPE_DISK
Definition: winnetwk.h:64
#define WN_MORE_DATA
Definition: winnetwk.h:117
#define WN_SUCCESS
Definition: winnetwk.h:111
#define WNetEnumResource
Definition: winnetwk.h:599
#define WNetOpenEnum
Definition: winnetwk.h:598
#define WN_NO_MORE_ENTRIES
Definition: winnetwk.h:146
#define LR_DEFAULTCOLOR
Definition: winuser.h:1087
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2053
DWORD WINAPI WNetCloseEnum(HANDLE hEnum)
Definition: wnet.c:1760

Referenced by DisconnectDlgProc().

◆ InitializeListView()

VOID InitializeListView ( HWND  hDlg)

Definition at line 15 of file SHDisconnectNetDrives.c.

16{
17 HWND hListView = GetDlgItem(hDlg, IDC_CONNECTEDDRIVELIST);
19 WCHAR szLetter[100], szPath[100];
20
21 if (hListView == NULL)
22 return;
23
24 LoadStringW(hInstance, IDS_DRIVE_LETTER, szLetter, _countof(szLetter));
26
28 column.pszText = szLetter;
29 column.cx = 75;
30 ListView_InsertColumn(hListView, 0, &column);
31
33 column.pszText = szPath;
34 column.cx = 150;
35 ListView_InsertColumn(hListView, 1, &column);
36}
#define IDS_DRIVE_LETTER
Definition: resource.h:19
#define IDS_NETWORK_PATH
Definition: resource.h:20
LPCWSTR szPath
Definition: env.c:37
#define ListView_InsertColumn(hwnd, iCol, pcol)
Definition: commctrl.h:2636
#define LVCF_WIDTH
Definition: commctrl.h:2587
#define LVCF_TEXT
Definition: commctrl.h:2588
#define LV_COLUMN
Definition: commctrl.h:2547
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by DisconnectDlgProc().

◆ SHDisconnectNetDrives()

HRESULT WINAPI SHDisconnectNetDrives ( PVOID  Unused)

Definition at line 193 of file SHDisconnectNetDrives.c.

194{
196 return S_OK;
197}
static INT_PTR CALLBACK DisconnectDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
#define IDD_DISCONNECTDRIVES
Definition: resource.h:12
#define S_OK
Definition: intsafe.h:52
#define DialogBoxW(i, t, p, f)
Definition: winuser.h:4399

◆ UpdateButtonStatus()

VOID UpdateButtonStatus ( WPARAM  wParam,
LPARAM  lParam,
HWND  hDlg 
)

Definition at line 114 of file SHDisconnectNetDrives.c.

115{
116 LPNMHDR pnmh = (LPNMHDR)lParam;
117 HWND hListView = GetDlgItem(hDlg, IDC_CONNECTEDDRIVELIST);
118 HWND hOkButton = GetDlgItem(hDlg, ID_OK);
119
120 if (pnmh->hwndFrom == hListView)
121 {
122 switch (pnmh->code)
123 {
124 case LVN_ITEMCHANGED:
125 if (ListView_GetSelectedCount(hListView))
126 {
127 EnableWindow(hOkButton, TRUE);
128 }
129 else
130 {
131 EnableWindow(hOkButton, FALSE);
132 }
133 break;
134 }
135 }
136}
#define ListView_GetSelectedCount(hwndLV)
Definition: commctrl.h:2709
#define LVN_ITEMCHANGED
Definition: commctrl.h:3131
UINT code
Definition: winuser.h:3159
HWND hwndFrom
Definition: winuser.h:3157
struct tagNMHDR * LPNMHDR

Referenced by DisconnectDlgProc().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( netplwiz  )

Variable Documentation

◆ hInstance

HINSTANCE hInstance