ReactOS  0.4.15-dev-439-g292f67a
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:
174  DisconnectDriveExit(hDlg);
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 }
#define IDI_DISCONNECT_NET_DRIVES
Definition: resource.h:15
static HICON
Definition: imagelist.c:84
#define TRUE
Definition: types.h:120
#define LR_SHARED
Definition: winuser.h:1090
#define IMAGE_ICON
Definition: winuser.h:212
#define SM_CYSMICON
Definition: winuser.h:1003
VOID UpdateButtonStatus(WPARAM wParam, LPARAM lParam, HWND hDlg)
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
WPARAM wParam
Definition: combotst.c:138
#define ICON_SMALL
Definition: tnclass.cpp:48
HINSTANCE hInstance
HANDLE WINAPI LoadImageW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_ UINT, _In_ int, _In_ int, _In_ UINT)
Definition: cursoricon.c:2172
HANDLE WINAPI CopyImage(_In_ HANDLE, _In_ UINT, _In_ int, _In_ int, _In_ UINT)
Definition: cursoricon.c:1956
LONG_PTR LPARAM
Definition: windef.h:208
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define LR_DEFAULTSIZE
Definition: winuser.h:1084
int WINAPI GetSystemMetrics(_In_ int)
#define SM_CXSMICON
Definition: winuser.h:1002
#define ID_OK
Definition: resource.h:9
#define WM_COMMAND
Definition: winuser.h:1722
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define LR_COPYFROMRESOURCE
Definition: winuser.h:1089
HICON hIcon
Definition: msconfig.c:44
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
VOID InitializeListView(HWND hDlg)
HICON hIconSm
Definition: msconfig.c:44
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define IDCANCEL
Definition: winuser.h:825
DWORD DisconnectDriveExit(HWND hDlg)
#define WM_INITDIALOG
Definition: winuser.h:1721
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
#define WM_NOTIFY
Definition: richedit.h:61
#define ICON_BIG
Definition: tnclass.cpp:51
VOID EnumerateConnectedDrives(HWND hDlg)

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 ListView_GetNextItem(hwnd, i, flags)
Definition: commctrl.h:2430
#define CONNECT_UPDATE_PROFILE
Definition: winnetwk.h:87
HRESULT hr
Definition: shlfolder.c:183
#define ListView_GetItemText(hwndLV, i, iSubItem_, pszText_, cchTextMax_)
Definition: commctrl.h:2680
#define WNetCancelConnection2
Definition: winnetwk.h:607
#define LVNI_SELECTED
Definition: commctrl.h:2420
int32_t INT
Definition: typedefs.h:57
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
#define IDC_CONNECTEDDRIVELIST
Definition: resource.h:8
char TCHAR
Definition: xmlstorage.h:189
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
LONG HRESULT
Definition: typedefs.h:78
#define _countof(array)
Definition: sndvol32.h:68
#define ID_OK
Definition: resource.h:9

Referenced by DisconnectDlgProc().

◆ EnumerateConnectedDrives()

VOID EnumerateConnectedDrives ( HWND  hDlg)

Definition at line 38 of file SHDisconnectNetDrives.c.

39 {
40  LV_ITEM item;
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 LV_ITEM
Definition: commctrl.h:2333
static HICON
Definition: imagelist.c:84
#define IMAGE_ICON
Definition: winuser.h:212
#define LVSIL_SMALL
Definition: commctrl.h:2295
#define WN_SUCCESS
Definition: winnetwk.h:111
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2022
LPSTR lpLocalName
Definition: winnetwk.h:171
#define ZeroMemory
Definition: winbase.h:1648
#define SM_CYSMICON
Definition: winuser.h:1003
#define ListView_InsertItem(hwnd, pitem)
Definition: commctrl.h:2404
#define ILC_COLOR32
Definition: commctrl.h:354
#define LVIF_TEXT
Definition: commctrl.h:2305
#define RESOURCE_CONNECTED
Definition: winnetwk.h:58
HIMAGELIST WINAPI ImageList_Create(INT cx, INT cy, UINT flags, INT cInitial, INT cGrow)
Definition: imagelist.c:804
HANDLE WINAPI LoadImageW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_ UINT, _In_ int, _In_ int, _In_ UINT)
Definition: cursoricon.c:2172
#define ListView_SetImageList(hwnd, himl, iImageList)
Definition: commctrl.h:2300
smooth NULL
Definition: ftsmooth.c:416
#define WNetOpenEnum
Definition: winnetwk.h:598
#define IDC_CONNECTEDDRIVELIST
Definition: resource.h:8
#define ListView_SetItemText(hwndLV, i, iSubItem_, pszText_)
Definition: commctrl.h:2687
#define GetProcessHeap()
Definition: compat.h:404
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define LVIF_IMAGE
Definition: commctrl.h:2306
int WINAPI GetSystemMetrics(_In_ int)
unsigned long DWORD
Definition: ntddk_ex.h:95
INT WINAPI ImageList_AddIcon(HIMAGELIST himl, HICON hIcon)
Definition: imagelist.c:540
#define SM_CXSMICON
Definition: winuser.h:1002
static const WCHAR L[]
Definition: oid.c:1250
#define ILC_MASK
Definition: commctrl.h:347
DWORD WINAPI WNetCloseEnum(HANDLE hEnum)
Definition: wnet.c:1760
#define WNetEnumResource
Definition: winnetwk.h:599
#define RESOURCETYPE_DISK
Definition: winnetwk.h:64
static ATOM item
Definition: dde.c:856
#define WN_NO_MORE_ENTRIES
Definition: winnetwk.h:146
LPSTR lpRemoteName
Definition: winnetwk.h:172
#define WN_MORE_DATA
Definition: winnetwk.h:117
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define LR_DEFAULTCOLOR
Definition: winuser.h:1077
static HMODULE hShell32
Definition: string.c:34
#define HeapFree(x, y, z)
Definition: compat.h:403
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54

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 
27  column.mask = LVCF_WIDTH | LVCF_TEXT;
28  column.pszText = szLetter;
29  column.cx = 75;
30  ListView_InsertColumn(hListView, 0, &column);
31 
32  column.mask = LVCF_WIDTH | LVCF_TEXT;
33  column.pszText = szPath;
34  column.cx = 150;
35  ListView_InsertColumn(hListView, 1, &column);
36 }
#define LVCF_WIDTH
Definition: commctrl.h:2583
#define LVCF_TEXT
Definition: commctrl.h:2584
#define LV_COLUMN
Definition: commctrl.h:2543
#define IDS_DRIVE_LETTER
Definition: resource.h:19
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define ListView_InsertColumn(hwnd, iCol, pcol)
Definition: commctrl.h:2632
HINSTANCE hInstance
smooth NULL
Definition: ftsmooth.c:416
#define IDC_CONNECTEDDRIVELIST
Definition: resource.h:8
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
#define IDS_NETWORK_PATH
Definition: resource.h:20
LPCWSTR szPath
Definition: env.c:35
GLenum GLenum GLvoid GLvoid * column
Definition: glext.h:5664

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
HINSTANCE hInstance
smooth NULL
Definition: ftsmooth.c:416
#define DialogBoxW(i, t, p, f)
Definition: winuser.h:4374
#define S_OK
Definition: intsafe.h:59
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582

◆ 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 TRUE
Definition: types.h:120
#define LVN_ITEMCHANGED
Definition: commctrl.h:3127
struct tagNMHDR * LPNMHDR
UINT code
Definition: winuser.h:3134
#define ListView_GetSelectedCount(hwndLV)
Definition: commctrl.h:2705
#define IDC_CONNECTEDDRIVELIST
Definition: resource.h:8
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define ID_OK
Definition: resource.h:9
HWND hwndFrom
Definition: winuser.h:3132
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
LPARAM lParam
Definition: combotst.c:139

Referenced by DisconnectDlgProc().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( netplwiz  )

Variable Documentation

◆ hInstance

HINSTANCE hInstance