ReactOS  0.4.15-dev-439-g292f67a
CDrivesFolder.cpp File Reference
#include <precomp.h>
#include <process.h>
Include dependency graph for CDrivesFolder.cpp:

Go to the source code of this file.

Classes

struct  THREAD_PARAMS
 
class  CDrivesFolderEnum
 

Macros

#define RETRY_COUNT   3
 
#define RETRY_SLEEP   250
 
#define CMDID_FORMAT   1
 
#define CMDID_EJECT   2
 
#define CMDID_DISCONNECT   3
 
#define MYCOMPUTERSHELLVIEWCOLUMNS   5
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (shell)
 
static BOOL TryToLockOrUnlockDrive (HANDLE hDrive, BOOL bLock)
 
static BOOL DoEjectDrive (const WCHAR *physical, UINT nDriveType, INT *pnStringID)
 
static BOOL CALLBACK EnumStubProc (HWND hwnd, LPARAM lParam)
 
static BOOL CALLBACK EnumStubProc2 (HWND hwnd, LPARAM lParam)
 
static unsigned __stdcall format_drive_thread (void *args)
 
static HRESULT DoFormatDrive (HWND hwnd, UINT nDriveNumber)
 
HRESULT CALLBACK DrivesContextMenuCallback (IShellFolder *psf, HWND hwnd, IDataObject *pdtobj, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
HRESULT CDrivesContextMenu_CreateInstance (PCIDLIST_ABSOLUTE pidlFolder, HWND hwnd, UINT cidl, PCUITEMID_CHILD_ARRAY apidl, IShellFolder *psf, IContextMenu **ppcm)
 
static HRESULT getIconLocationForDrive (IShellFolder *psf, PCITEMID_CHILD pidl, UINT uFlags, LPWSTR szIconFile, UINT cchMax, int *piIndex, UINT *pwFlags)
 
BOOL IsDriveFloppyA (LPCSTR pszDriveRoot)
 
HRESULT CDrivesExtractIcon_CreateInstance (IShellFolder *psf, LPCITEMIDLIST pidl, REFIID riid, LPVOID *ppvOut)
 
static BOOL _ILIsControlPanel (LPCITEMIDLIST pidl)
 

Variables

static int iDriveIconIds [7]
 
static int iDriveTypeIds [7]
 
static const shvheader MyComputerSFHeader []
 
static const DWORD dwComputerAttributes
 
static const DWORD dwControlPanelAttributes
 
static const DWORD dwDriveAttributes
 

Macro Definition Documentation

◆ CMDID_DISCONNECT

#define CMDID_DISCONNECT   3

◆ CMDID_EJECT

#define CMDID_EJECT   2

◆ CMDID_FORMAT

#define CMDID_FORMAT   1

◆ MYCOMPUTERSHELLVIEWCOLUMNS

#define MYCOMPUTERSHELLVIEWCOLUMNS   5

Definition at line 539 of file CDrivesFolder.cpp.

◆ RETRY_COUNT

#define RETRY_COUNT   3

Definition at line 62 of file CDrivesFolder.cpp.

◆ RETRY_SLEEP

#define RETRY_SLEEP   250

Definition at line 63 of file CDrivesFolder.cpp.

Function Documentation

◆ _ILIsControlPanel()

static BOOL _ILIsControlPanel ( LPCITEMIDLIST  pidl)
static

Definition at line 824 of file CDrivesFolder.cpp.

825 {
826  GUID *guid = _ILGetGUIDPointer(pidl);
827 
828  TRACE("(%p)\n", pidl);
829 
830  if (guid)
831  return IsEqualIID(*guid, CLSID_ControlPanel);
832  return FALSE;
833 }
const GUID * guid
#define TRACE(s)
Definition: solgame.cpp:4
IID * _ILGetGUIDPointer(LPCITEMIDLIST pidl)
Definition: pidl.c:2308
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95

Referenced by CDrivesFolder::GetAttributesOf().

◆ CDrivesContextMenu_CreateInstance()

HRESULT CDrivesContextMenu_CreateInstance ( PCIDLIST_ABSOLUTE  pidlFolder,
HWND  hwnd,
UINT  cidl,
PCUITEMID_CHILD_ARRAY  apidl,
IShellFolder psf,
IContextMenu **  ppcm 
)

Definition at line 392 of file CDrivesFolder.cpp.

398 {
399  HKEY hKeys[2];
400  UINT cKeys = 0;
401  AddClassKeyToArray(L"Drive", hKeys, &cKeys);
402  AddClassKeyToArray(L"Folder", hKeys, &cKeys);
403 
404  return CDefFolderMenu_Create2(pidlFolder, hwnd, cidl, apidl, psf, DrivesContextMenuCallback, cKeys, hKeys, ppcm);
405 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
void AddClassKeyToArray(const WCHAR *szClass, HKEY *array, UINT *cKeys)
Definition: shlfolder.cpp:267
HRESULT CALLBACK DrivesContextMenuCallback(IShellFolder *psf, HWND hwnd, IDataObject *pdtobj, UINT uMsg, WPARAM wParam, LPARAM lParam)
static const WCHAR L[]
Definition: oid.c:1250
unsigned int UINT
Definition: ndis.h:50
HRESULT WINAPI CDefFolderMenu_Create2(PCIDLIST_ABSOLUTE pidlFolder, HWND hwnd, UINT cidl, PCUITEMID_CHILD_ARRAY apidl, IShellFolder *psf, LPFNDFMCALLBACK lpfn, UINT nKeys, const HKEY *ahkeyClsKeys, IContextMenu **ppcm)

Referenced by CDrivesFolder::GetUIObjectOf().

◆ CDrivesExtractIcon_CreateInstance()

HRESULT CDrivesExtractIcon_CreateInstance ( IShellFolder psf,
LPCITEMIDLIST  pidl,
REFIID  riid,
LPVOID ppvOut 
)

Definition at line 454 of file CDrivesFolder.cpp.

455 {
456  CComPtr<IDefaultExtractIconInit> initIcon;
458  if (FAILED_UNEXPECTEDLY(hr))
459  return hr;
460 
461  CHAR* pszDrive = _ILGetDataPointer(pidl)->u.drive.szDriveName;
462  UINT DriveType = GetDriveTypeA(pszDrive);
463  if (DriveType > DRIVE_RAMDISK)
465 
466  WCHAR wTemp[MAX_PATH];
467  int icon_idx;
468  UINT flags = 0;
469  if ((DriveType == DRIVE_FIXED || DriveType == DRIVE_UNKNOWN) &&
470  (HCR_GetIconW(L"Drive", wTemp, NULL, MAX_PATH, &icon_idx)))
471  {
472  initIcon->SetNormalIcon(wTemp, icon_idx);
473  }
474  else if (SUCCEEDED(getIconLocationForDrive(psf, pidl, 0, wTemp, _countof(wTemp),
475  &icon_idx, &flags)))
476  {
477  initIcon->SetNormalIcon(wTemp, icon_idx);
478  }
479  else
480  {
481  if (DriveType == DRIVE_REMOVABLE && !IsDriveFloppyA(pszDrive))
482  {
483  icon_idx = IDI_SHELL_REMOVEABLE;
484  }
485  else
486  {
487  icon_idx = iDriveIconIds[DriveType];
488  }
489  initIcon->SetNormalIcon(swShell32Name, -icon_idx);
490  }
491 
492  return initIcon->QueryInterface(riid, ppvOut);
493 }
LPPIDLDATA _ILGetDataPointer(LPCITEMIDLIST pidl)
Definition: pidl.c:2170
UINT WINAPI GetDriveTypeA(IN LPCSTR lpRootPathName)
Definition: disk.c:468
HRESULT hr
Definition: shlfolder.c:183
REFIID riid
Definition: precomp.h:44
BOOL HCR_GetIconW(LPCWSTR szClass, LPWSTR szDest, LPCWSTR szName, DWORD len, int *picon_idx)
Definition: classes.c:294
char CHAR
Definition: xmlstorage.h:175
#define DRIVE_RAMDISK
Definition: winbase.h:252
WCHAR swShell32Name[MAX_PATH]
Definition: folders.cpp:22
#define IDI_SHELL_REMOVEABLE
Definition: shresdef.h:486
UINT DriveType
BOOL IsDriveFloppyA(LPCSTR pszDriveRoot)
Definition: drvdefext.cpp:373
#define IID_PPV_ARG(Itype, ppType)
#define DRIVE_REMOVABLE
Definition: winbase.h:248
smooth NULL
Definition: ftsmooth.c:416
static HRESULT getIconLocationForDrive(IShellFolder *psf, PCITEMID_CHILD pidl, UINT uFlags, LPWSTR szIconFile, UINT cchMax, int *piIndex, UINT *pwFlags)
#define DRIVE_UNKNOWN
Definition: winbase.h:253
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:78
#define _countof(array)
Definition: sndvol32.h:68
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:71
#define MAX_PATH
Definition: compat.h:26
GLbitfield flags
Definition: glext.h:7161
static const WCHAR L[]
Definition: oid.c:1250
static int iDriveIconIds[7]
HRESULT WINAPI SHCreateDefaultExtractIcon(REFIID riid, void **ppv)
#define DRIVE_FIXED
Definition: winbase.h:249
unsigned int UINT
Definition: ndis.h:50
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by CDrivesFolder::GetUIObjectOf().

◆ DoEjectDrive()

static BOOL DoEjectDrive ( const WCHAR physical,
UINT  nDriveType,
INT pnStringID 
)
static

Definition at line 84 of file CDrivesFolder.cpp.

85 {
86  /* GENERIC_WRITE isn't needed for umount */
87  DWORD dwAccessMode = GENERIC_READ;
88  DWORD dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;
89 
90  HANDLE hDrive = CreateFile(physical, dwAccessMode, dwShareMode, 0, OPEN_EXISTING, 0, NULL);
91  if (hDrive == INVALID_HANDLE_VALUE)
92  return FALSE;
93 
94  BOOL bResult, bNeedUnlock = FALSE;
95  DWORD dwBytesReturned, dwError = NO_ERROR;
96  PREVENT_MEDIA_REMOVAL removal;
97  do
98  {
99  bResult = TryToLockOrUnlockDrive(hDrive, TRUE);
100  if (!bResult)
101  {
102  dwError = GetLastError();
103  *pnStringID = IDS_CANTLOCKVOLUME; /* Unable to lock volume */
104  break;
105  }
106  bResult = DeviceIoControl(hDrive, FSCTL_DISMOUNT_VOLUME, NULL, 0, NULL, 0, &dwBytesReturned, NULL);
107  if (!bResult)
108  {
109  dwError = GetLastError();
110  *pnStringID = IDS_CANTDISMOUNTVOLUME; /* Unable to dismount volume */
111  bNeedUnlock = TRUE;
112  break;
113  }
114  removal.PreventMediaRemoval = FALSE;
115  bResult = DeviceIoControl(hDrive, IOCTL_STORAGE_MEDIA_REMOVAL, &removal, sizeof(removal), NULL,
116  0, &dwBytesReturned, NULL);
117  if (!bResult)
118  {
119  *pnStringID = IDS_CANTEJECTMEDIA; /* Unable to eject media */
120  dwError = GetLastError();
121  bNeedUnlock = TRUE;
122  break;
123  }
124  bResult = DeviceIoControl(hDrive, IOCTL_STORAGE_EJECT_MEDIA, NULL, 0, NULL, 0, &dwBytesReturned, NULL);
125  if (!bResult)
126  {
127  *pnStringID = IDS_CANTEJECTMEDIA; /* Unable to eject media */
128  dwError = GetLastError();
129  bNeedUnlock = TRUE;
130  break;
131  }
132  } while (0);
133 
134  if (bNeedUnlock)
135  {
136  TryToLockOrUnlockDrive(hDrive, FALSE);
137  }
138 
139  CloseHandle(hDrive);
140 
141  SetLastError(dwError);
142  return bResult;
143 }
#define IDS_CANTDISMOUNTVOLUME
Definition: shresdef.h:139
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:407
#define IOCTL_STORAGE_MEDIA_REMOVAL
Definition: ntddstor.h:93
static BOOL TryToLockOrUnlockDrive(HANDLE hDrive, BOOL bLock)
#define INVALID_HANDLE_VALUE
Definition: compat.h:400
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define NO_ERROR
Definition: dderror.h:5
#define FILE_SHARE_READ
Definition: compat.h:125
unsigned int BOOL
Definition: ntddk_ex.h:94
#define IOCTL_STORAGE_EJECT_MEDIA
Definition: ntddstor.h:96
#define IDS_CANTLOCKVOLUME
Definition: shresdef.h:138
smooth NULL
Definition: ftsmooth.c:416
#define OPEN_EXISTING
Definition: compat.h:435
#define FSCTL_DISMOUNT_VOLUME
Definition: nt_native.h:834
#define IDS_CANTEJECTMEDIA
Definition: shresdef.h:140
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:418
BOOLEAN PreventMediaRemoval
Definition: ntddstor.h:251
#define GENERIC_READ
Definition: compat.h:124
BOOL WINAPI DeviceIoControl(IN HANDLE hDevice, IN DWORD dwIoControlCode, IN LPVOID lpInBuffer OPTIONAL, IN DWORD nInBufferSize OPTIONAL, OUT LPVOID lpOutBuffer OPTIONAL, IN DWORD nOutBufferSize OPTIONAL, OUT LPDWORD lpBytesReturned OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: deviceio.c:136
IN OUT PVCB OUT PDIRENT OUT PBCB IN BOOLEAN CreateFile
Definition: fatprocs.h:913

Referenced by DrivesContextMenuCallback().

◆ DoFormatDrive()

static HRESULT DoFormatDrive ( HWND  hwnd,
UINT  nDriveNumber 
)
static

Definition at line 239 of file CDrivesFolder.cpp.

240 {
242  params->nDriveNumber = nDriveNumber;
243 
244  // Create thread to avoid locked.
245  unsigned tid;
247  if (hThread == NULL)
248  {
249  delete params;
250  return E_FAIL;
251  }
252 
254 
255  return S_OK;
256 }
#define CloseHandle
Definition: compat.h:407
_CRTIMP uintptr_t __cdecl _beginthreadex(_In_opt_ void *_Security, _In_ unsigned _StackSize, _In_ unsigned(__stdcall *_StartAddress)(void *), _In_opt_ void *_ArgList, _In_ unsigned _InitFlag, _Out_opt_ unsigned *_ThrdAddr)
#define E_FAIL
Definition: ddrawi.h:102
GLenum const GLfloat * params
Definition: glext.h:5645
smooth NULL
Definition: ftsmooth.c:416
PVOID HANDLE
Definition: typedefs.h:72
static unsigned __stdcall format_drive_thread(void *args)
#define S_OK
Definition: intsafe.h:59
HANDLE hThread
Definition: wizard.c:27
static TfClientId tid

Referenced by DrivesContextMenuCallback().

◆ DrivesContextMenuCallback()

HRESULT CALLBACK DrivesContextMenuCallback ( IShellFolder psf,
HWND  hwnd,
IDataObject pdtobj,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 258 of file CDrivesFolder.cpp.

264 {
265  if (uMsg != DFM_MERGECONTEXTMENU && uMsg != DFM_INVOKECOMMAND)
266  return S_OK;
267 
268  PIDLIST_ABSOLUTE pidlFolder;
269  PUITEMID_CHILD *apidl;
270  UINT cidl;
271  UINT nDriveType;
272  DWORD dwFlags;
273  HRESULT hr = SH_GetApidlFromDataObject(pdtobj, &pidlFolder, &apidl, &cidl);
274  if (FAILED_UNEXPECTEDLY(hr))
275  return hr;
276 
277  char szDrive[8] = {0};
278  if (!_ILGetDrive(apidl[0], szDrive, sizeof(szDrive)))
279  {
280  ERR("pidl is not a drive\n");
281  SHFree(pidlFolder);
282  _ILFreeaPidl(apidl, cidl);
283  return E_FAIL;
284  }
285  nDriveType = GetDriveTypeA(szDrive);
286  GetVolumeInformationA(szDrive, NULL, 0, NULL, NULL, &dwFlags, NULL, 0);
287 
288 // custom command IDs
289 #define CMDID_FORMAT 1
290 #define CMDID_EJECT 2
291 #define CMDID_DISCONNECT 3
292 
293  if (uMsg == DFM_MERGECONTEXTMENU)
294  {
295  QCMINFO *pqcminfo = (QCMINFO *)lParam;
296 
297  UINT idCmdFirst = pqcminfo->idCmdFirst;
298  if (!(dwFlags & FILE_READ_ONLY_VOLUME) && nDriveType != DRIVE_REMOTE)
299  {
300  /* add separator and Format */
301  UINT idCmd = idCmdFirst + CMDID_FORMAT;
302  _InsertMenuItemW(pqcminfo->hmenu, pqcminfo->indexMenu++, TRUE, 0, MFT_SEPARATOR, NULL, 0);
304  }
305  if (nDriveType == DRIVE_REMOVABLE || nDriveType == DRIVE_CDROM)
306  {
307  /* add separator and Eject */
308  UINT idCmd = idCmdFirst + CMDID_EJECT;
309  _InsertMenuItemW(pqcminfo->hmenu, pqcminfo->indexMenu++, TRUE, 0, MFT_SEPARATOR, NULL, 0);
311  }
312  if (nDriveType == DRIVE_REMOTE)
313  {
314  /* add separator and Disconnect */
315  UINT idCmd = idCmdFirst + CMDID_DISCONNECT;
316  _InsertMenuItemW(pqcminfo->hmenu, pqcminfo->indexMenu++, TRUE, 0, MFT_SEPARATOR, NULL, 0);
318  }
319 
320  pqcminfo->idCmdFirst += 3;
321  }
322  else if (uMsg == DFM_INVOKECOMMAND)
323  {
324  WCHAR wszBuf[4] = L"A:\\";
325  wszBuf[0] = (WCHAR)szDrive[0];
326 
327  INT nStringID = 0;
328  DWORD dwError = NO_ERROR;
329 
330  if (wParam == DFM_CMD_PROPERTIES)
331  {
332  hr = SH_ShowDriveProperties(wszBuf, pidlFolder, apidl);
333  if (FAILED(hr))
334  {
335  dwError = ERROR_CAN_NOT_COMPLETE;
336  nStringID = IDS_CANTSHOWPROPERTIES;
337  }
338  }
339  else
340  {
341  if (wParam == CMDID_FORMAT)
342  {
343  hr = DoFormatDrive(hwnd, szDrive[0] - 'A');
344  }
345  else if (wParam == CMDID_EJECT)
346  {
347  /* do eject */
348  WCHAR physical[10];
349  wsprintfW(physical, _T("\\\\.\\%c:"), szDrive[0]);
350 
351  if (DoEjectDrive(physical, nDriveType, &nStringID))
352  {
354  }
355  else
356  {
357  dwError = GetLastError();
358  }
359  }
360  else if (wParam == CMDID_DISCONNECT)
361  {
362  /* do disconnect */
363  wszBuf[2] = UNICODE_NULL;
364  dwError = WNetCancelConnection2W(wszBuf, 0, FALSE);
365  if (dwError == NO_ERROR)
366  {
368  }
369  else
370  {
371  nStringID = IDS_CANTDISCONNECT;
372  }
373  }
374  }
375 
376  if (nStringID != 0)
377  {
378  /* show error message */
379  WCHAR szFormat[128], szMessage[128];
380  LoadStringW(shell32_hInstance, nStringID, szFormat, _countof(szFormat));
381  wsprintfW(szMessage, szFormat, dwError);
382  MessageBoxW(hwnd, szMessage, NULL, MB_ICONERROR);
383  }
384  }
385 
386  SHFree(pidlFolder);
387  _ILFreeaPidl(apidl, cidl);
388 
389  return hr;
390 }
int WINAPIV wsprintfW(_Out_ LPWSTR, _In_ _Printf_format_string_ LPCWSTR,...)
void WINAPI _InsertMenuItemW(HMENU hmenu, UINT indexMenu, BOOL fByPosition, UINT wID, UINT fType, LPCWSTR dwTypeData, UINT fState)
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define MFT_STRING
Definition: winuser.h:741
#define TRUE
Definition: types.h:120
UINT WINAPI GetDriveTypeA(IN LPCSTR lpRootPathName)
Definition: disk.c:468
#define CMDID_EJECT
HRESULT hr
Definition: shlfolder.c:183
#define CMDID_FORMAT
ITEMID_CHILD UNALIGNED * PUITEMID_CHILD
Definition: shtypes.idl:68
#define CMDID_DISCONNECT
HMENU hmenu
Definition: shlobj.h:1315
#define IDS_CANTSHOWPROPERTIES
Definition: shresdef.h:141
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
BOOL WINAPI GetVolumeInformationA(IN LPCSTR lpRootPathName, IN LPSTR lpVolumeNameBuffer, IN DWORD nVolumeNameSize, OUT LPDWORD lpVolumeSerialNumber OPTIONAL, OUT LPDWORD lpMaximumComponentLength OPTIONAL, OUT LPDWORD lpFileSystemFlags OPTIONAL, OUT LPSTR lpFileSystemNameBuffer OPTIONAL, IN DWORD nFileSystemNameSize)
Definition: volume.c:32
#define NO_ERROR
Definition: dderror.h:5
#define E_FAIL
Definition: ddrawi.h:102
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
int32_t INT
Definition: typedefs.h:57
WPARAM wParam
Definition: combotst.c:138
#define DRIVE_REMOVABLE
Definition: winbase.h:248
#define DRIVE_REMOTE
Definition: winbase.h:250
#define MFS_ENABLED
Definition: winuser.h:745
#define DRIVE_CDROM
Definition: machpc98.h:115
HINSTANCE shell32_hInstance
Definition: misc.cpp:82
#define IDS_FORMATDRIVE
Definition: shresdef.h:214
#define UNICODE_NULL
#define ERROR_CAN_NOT_COMPLETE
Definition: winerror.h:582
HRESULT SH_GetApidlFromDataObject(IDataObject *pDataObject, PIDLIST_ABSOLUTE *ppidlfolder, PUITEMID_CHILD **apidlItems, UINT *pcidl)
Definition: shlfolder.cpp:327
#define DFM_INVOKECOMMAND
Definition: precomp.h:45
smooth NULL
Definition: ftsmooth.c:416
UINT indexMenu
Definition: shlobj.h:1316
static HRESULT DoFormatDrive(HWND hwnd, UINT nDriveNumber)
#define _T(x)
Definition: vfdio.h:22
#define SHCNE_MEDIAREMOVED
Definition: shlobj.h:1735
int WINAPI MessageBoxW(_In_opt_ HWND, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_ UINT)
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:78
UINT idCmdFirst
Definition: shlobj.h:1317
#define _countof(array)
Definition: sndvol32.h:68
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:71
#define DFM_MERGECONTEXTMENU
Definition: precomp.h:44
#define DFM_CMD_PROPERTIES
Definition: shlobj.h:2429
unsigned long DWORD
Definition: ntddk_ex.h:95
#define IDS_DISCONNECT
Definition: shresdef.h:229
#define MFT_SEPARATOR
Definition: winuser.h:739
EXTERN_C void WINAPI SHChangeNotify(LONG wEventId, UINT uFlags, LPCVOID dwItem1, LPCVOID dwItem2)
static const WCHAR L[]
Definition: oid.c:1250
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define MB_ICONERROR
Definition: winuser.h:781
#define IDS_CANTDISCONNECT
Definition: shresdef.h:142
void _ILFreeaPidl(LPITEMIDLIST *apidl, UINT cidl)
Definition: pidl.c:2629
DWORD WINAPI WNetCancelConnection2W(LPCWSTR lpName, DWORD dwFlags, BOOL fForce)
Definition: wnet.c:2418
#define SHCNF_PATHW
Definition: shlobj.h:1764
#define ERR(fmt,...)
Definition: debug.h:110
#define S_OK
Definition: intsafe.h:59
HRESULT SH_ShowDriveProperties(WCHAR *pwszDrive, LPCITEMIDLIST pidlFolder, PCUITEMID_CHILD_ARRAY apidl)
Definition: drive.cpp:120
unsigned int UINT
Definition: ndis.h:50
void WINAPI SHFree(LPVOID pv)
Definition: shellole.c:331
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define FILE_READ_ONLY_VOLUME
Definition: from_kernel.h:246
static BOOL DoEjectDrive(const WCHAR *physical, UINT nDriveType, INT *pnStringID)
DWORD _ILGetDrive(LPCITEMIDLIST pidl, LPSTR pOut, UINT uSize)
Definition: pidl.c:1849
LPARAM lParam
Definition: combotst.c:139
#define SHCNE_DRIVEREMOVED
Definition: shlobj.h:1736
#define SHCNF_FLUSHNOWAIT
Definition: shlobj.h:1768
#define IDS_EJECT
Definition: shresdef.h:228

Referenced by CDrivesContextMenu_CreateInstance().

◆ EnumStubProc()

static BOOL CALLBACK EnumStubProc ( HWND  hwnd,
LPARAM  lParam 
)
static

Definition at line 147 of file CDrivesFolder.cpp.

148 {
149  CSimpleArray<HWND> *pStubs = reinterpret_cast<CSimpleArray<HWND> *>(lParam);
150 
151  WCHAR szClass[64];
152  GetClassNameW(hwnd, szClass, _countof(szClass));
153 
154  if (lstrcmpiW(szClass, L"StubWindow32") == 0)
155  {
156  pStubs->Add(hwnd);
157  }
158 
159  return TRUE;
160 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define TRUE
Definition: types.h:120
int WINAPI lstrcmpiW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:194
int WINAPI GetClassNameW(_In_ HWND hWnd, _Out_writes_to_(nMaxCount, return) LPWSTR lpClassName, _In_ int nMaxCount)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
static const WCHAR L[]
Definition: oid.c:1250
LPARAM lParam
Definition: combotst.c:139

Referenced by format_drive_thread().

◆ EnumStubProc2()

static BOOL CALLBACK EnumStubProc2 ( HWND  hwnd,
LPARAM  lParam 
)
static

Definition at line 164 of file CDrivesFolder.cpp.

165 {
166  HWND *phwnd = reinterpret_cast<HWND *>(lParam);
167 
168  if (phwnd[0] == GetWindow(hwnd, GW_OWNER))
169  {
170  phwnd[1] = hwnd;
171  return FALSE;
172  }
173 
174  return TRUE;
175 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define TRUE
Definition: types.h:120
HWND WINAPI GetWindow(_In_ HWND, _In_ UINT)
#define GW_OWNER
Definition: winuser.h:761
LPARAM lParam
Definition: combotst.c:139

Referenced by format_drive_thread().

◆ format_drive_thread()

static unsigned __stdcall format_drive_thread ( void args)
static

Definition at line 183 of file CDrivesFolder.cpp.

184 {
186  UINT nDriveNumber = params->nDriveNumber;
187  LONG_PTR nProp = nDriveNumber | 0x7F00;
188 
189  // Search the stub windows that already exist.
190  CSimpleArray<HWND> old_stubs;
191  EnumWindows(EnumStubProc, (LPARAM)&old_stubs);
192 
193  for (INT n = 0; n < old_stubs.GetSize(); ++n)
194  {
195  HWND hwndStub = old_stubs[n];
196 
197  // The target stub window has the prop.
198  if (GetPropW(hwndStub, L"DriveNumber") == (HANDLE)nProp)
199  {
200  // Found.
201  HWND ahwnd[2];
202  ahwnd[0] = hwndStub;
203  ahwnd[1] = NULL;
205 
206  // Activate.
207  BringWindowToTop(ahwnd[1]);
208 
209  delete params;
210  return 0;
211  }
212  }
213 
214  // Create a stub window.
218  if (!stub.Create(NULL, NULL, NULL, style, exstyle))
219  {
220  ERR("StubWindow32 creation failed\n");
221  delete params;
222  return 0;
223  }
224 
225  // Add prop to the target stub window.
226  SetPropW(stub, L"DriveNumber", (HANDLE)nProp);
227 
228  // Do format.
229  SHFormatDrive(stub, nDriveNumber, SHFMT_ID_DEFAULT, 0);
230 
231  // Clean up.
232  RemovePropW(stub, L"DriveNumber");
233  stub.DestroyWindow();
234  delete params;
235 
236  return 0;
237 }
#define WS_CLIPSIBLINGS
Definition: pedump.c:618
#define WS_DISABLED
Definition: pedump.c:621
#define WS_EX_WINDOWEDGE
Definition: winuser.h:407
static BOOL CALLBACK EnumStubProc(HWND hwnd, LPARAM lParam)
Definition: stubgen.c:11
GLdouble n
Definition: glext.h:7729
#define SHFMT_ID_DEFAULT
Definition: shlobj.h:297
Definition: match.c:390
int32_t INT
Definition: typedefs.h:57
HANDLE WINAPI RemovePropW(_In_ HWND, _In_ LPCWSTR)
struct _stub stub
GLenum const GLfloat * params
Definition: glext.h:5645
BOOL WINAPI BringWindowToTop(_In_ HWND)
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
#define WS_CAPTION
Definition: pedump.c:624
BOOL WINAPI SetPropW(_In_ HWND, _In_ LPCWSTR, _In_opt_ HANDLE)
BOOL WINAPI EnumWindows(_In_ WNDENUMPROC, _In_ LPARAM)
unsigned long DWORD
Definition: ntddk_ex.h:95
PVOID HANDLE
Definition: typedefs.h:72
static const WCHAR L[]
Definition: oid.c:1250
#define ERR(fmt,...)
Definition: debug.h:110
DWORD WINAPI SHFormatDrive(HWND hwnd, UINT drive, UINT fmtID, UINT options)
Definition: drive.cpp:685
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
unsigned int UINT
Definition: ndis.h:50
HANDLE WINAPI GetPropW(_In_ HWND, _In_ LPCWSTR)
static BOOL CALLBACK EnumStubProc2(HWND hwnd, LPARAM lParam)
#define WS_EX_APPWINDOW
Definition: winuser.h:383
Arabic default style
Definition: afstyles.h:93

Referenced by DoFormatDrive().

◆ getIconLocationForDrive()

static HRESULT getIconLocationForDrive ( IShellFolder psf,
PCITEMID_CHILD  pidl,
UINT  uFlags,
LPWSTR  szIconFile,
UINT  cchMax,
int piIndex,
UINT pwFlags 
)
static

Definition at line 408 of file CDrivesFolder.cpp.

410 {
411  WCHAR wszPath[MAX_PATH];
412  WCHAR wszAutoRunInfPath[MAX_PATH];
413  WCHAR wszValue[MAX_PATH], wszTemp[MAX_PATH];
414  static const WCHAR wszAutoRunInf[] = { 'a','u','t','o','r','u','n','.','i','n','f',0 };
415  static const WCHAR wszAutoRun[] = { 'a','u','t','o','r','u','n',0 };
416 
417  // get path
418  if (!ILGetDisplayNameExW(psf, pidl, wszPath, 0))
419  return E_FAIL;
420  if (!PathIsDirectoryW(wszPath))
421  return E_FAIL;
422 
423  // build the full path of autorun.inf
424  StringCchCopyW(wszAutoRunInfPath, _countof(wszAutoRunInfPath), wszPath);
425  PathAppendW(wszAutoRunInfPath, wszAutoRunInf);
426 
427  // autorun.inf --> wszValue
428  if (GetPrivateProfileStringW(wszAutoRun, L"icon", NULL, wszValue, _countof(wszValue),
429  wszAutoRunInfPath) && wszValue[0] != 0)
430  {
431  // wszValue --> wszTemp
432  ExpandEnvironmentStringsW(wszValue, wszTemp, _countof(wszTemp));
433 
434  // parse the icon location
435  *piIndex = PathParseIconLocationW(wszTemp);
436 
437  // wszPath + wszTemp --> wszPath
438  if (PathIsRelativeW(wszTemp))
439  PathAppendW(wszPath, wszTemp);
440  else
441  StringCchCopyW(wszPath, _countof(wszPath), wszTemp);
442 
443  // wszPath --> szIconFile
444  GetFullPathNameW(wszPath, cchMax, szIconFile, NULL);
445 
446  return S_OK;
447  }
448 
449  return E_FAIL;
450 }
BOOL WINAPI PathIsDirectoryW(LPCWSTR lpszPath)
Definition: path.c:1702
INT WINAPI GetPrivateProfileStringW(LPCWSTR section, LPCWSTR entry, LPCWSTR def_val, LPWSTR buffer, UINT len, LPCWSTR filename)
Definition: profile.c:1142
BOOL WINAPI PathIsRelativeW(LPCWSTR lpszPath)
Definition: path.c:1558
DWORD WINAPI GetFullPathNameW(IN LPCWSTR lpFileName, IN DWORD nBufferLength, OUT LPWSTR lpBuffer, OUT LPWSTR *lpFilePart)
Definition: path.c:1105
#define E_FAIL
Definition: ddrawi.h:102
BOOL WINAPI PathAppendW(LPWSTR lpszPath, LPCWSTR lpszAppend)
Definition: path.c:121
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
smooth NULL
Definition: ftsmooth.c:416
BOOL ILGetDisplayNameExW(LPSHELLFOLDER psf, LPCITEMIDLIST pidl, LPWSTR path, DWORD type)
Definition: pidl.c:91
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
#define MAX_PATH
Definition: compat.h:26
UINT cchMax
static const WCHAR L[]
Definition: oid.c:1250
int WINAPI PathParseIconLocationW(LPWSTR lpszPath)
Definition: path.c:1087
#define S_OK
Definition: intsafe.h:59
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:519

Referenced by CDrivesExtractIcon_CreateInstance().

◆ IsDriveFloppyA()

BOOL IsDriveFloppyA ( LPCSTR  pszDriveRoot)

Definition at line 373 of file drvdefext.cpp.

374 {
375  WCHAR szRoot[8];
376  MultiByteToWideChar(CP_ACP, 0, pszDriveRoot, -1, szRoot, _countof(szRoot));
377  return IsDriveFloppyW(szRoot);
378 }
#define CP_ACP
Definition: compat.h:99
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
#define MultiByteToWideChar
Definition: compat.h:100
BOOL IsDriveFloppyW(LPCWSTR pszDriveRoot)
Definition: drvdefext.cpp:307

Referenced by CDrivesExtractIcon_CreateInstance(), and CDrivesFolder::GetDetailsOf().

◆ TryToLockOrUnlockDrive()

static BOOL TryToLockOrUnlockDrive ( HANDLE  hDrive,
BOOL  bLock 
)
static

Definition at line 64 of file CDrivesFolder.cpp.

65 {
66  DWORD dwError, dwBytesReturned;
67  DWORD dwCode = (bLock ? FSCTL_LOCK_VOLUME : FSCTL_UNLOCK_VOLUME);
68  for (DWORD i = 0; i < RETRY_COUNT; ++i)
69  {
70  if (DeviceIoControl(hDrive, dwCode, NULL, 0, NULL, 0, &dwBytesReturned, NULL))
71  return TRUE;
72 
73  dwError = GetLastError();
74  if (dwError == ERROR_INVALID_FUNCTION)
75  break; /* don't sleep if function is not implemented */
76 
78  }
79  SetLastError(dwError);
80  return FALSE;
81 }
#define FSCTL_UNLOCK_VOLUME
Definition: nt_native.h:833
#define TRUE
Definition: types.h:120
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790
#define ERROR_INVALID_FUNCTION
Definition: dderror.h:6
#define RETRY_SLEEP
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define RETRY_COUNT
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
smooth NULL
Definition: ftsmooth.c:416
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:418
BOOL WINAPI DeviceIoControl(IN HANDLE hDevice, IN DWORD dwIoControlCode, IN LPVOID lpInBuffer OPTIONAL, IN DWORD nInBufferSize OPTIONAL, OUT LPVOID lpOutBuffer OPTIONAL, IN DWORD nOutBufferSize OPTIONAL, OUT LPDWORD lpBytesReturned OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: deviceio.c:136
#define FSCTL_LOCK_VOLUME
Definition: nt_native.h:832

Referenced by DoEjectDrive().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( shell  )

Variable Documentation

◆ dwComputerAttributes

const DWORD dwComputerAttributes
static
Initial value:
=
SFGAO_CANRENAME | SFGAO_CANDELETE | SFGAO_HASPROPSHEET | SFGAO_DROPTARGET |
SFGAO_FILESYSANCESTOR | SFGAO_FOLDER | SFGAO_HASSUBFOLDER

Definition at line 541 of file CDrivesFolder.cpp.

Referenced by CDrivesFolder::GetAttributesOf().

◆ dwControlPanelAttributes

const DWORD dwControlPanelAttributes
static
Initial value:
=
SFGAO_HASSUBFOLDER | SFGAO_FOLDER | SFGAO_CANLINK

Definition at line 544 of file CDrivesFolder.cpp.

Referenced by CControlPanelFolder::GetAttributesOf(), and CDrivesFolder::GetAttributesOf().

◆ dwDriveAttributes

const DWORD dwDriveAttributes
static
Initial value:
=
SFGAO_HASSUBFOLDER | SFGAO_FILESYSTEM | SFGAO_FOLDER | SFGAO_FILESYSANCESTOR |
SFGAO_DROPTARGET | SFGAO_HASPROPSHEET | SFGAO_CANRENAME | SFGAO_CANLINK

Definition at line 546 of file CDrivesFolder.cpp.

Referenced by CDrivesFolder::GetAttributesOf(), and CDrivesFolder::ParseDisplayName().

◆ iDriveIconIds

int iDriveIconIds[7]
static
Initial value:
}
#define IDI_SHELL_DRIVE
Definition: shresdef.h:487
#define IDI_SHELL_3_14_FLOPPY
Definition: shresdef.h:485
#define IDI_SHELL_CDROM
Definition: shresdef.h:490
#define IDI_SHELL_RAMDISK
Definition: shresdef.h:491
#define IDI_SHELL_NETDRIVE
Definition: shresdef.h:488

Definition at line 40 of file CDrivesFolder.cpp.

Referenced by CDrivesExtractIcon_CreateInstance().

◆ iDriveTypeIds

int iDriveTypeIds[7]
static
Initial value:
}
#define IDS_DRIVE_CDROM
Definition: shresdef.h:106
#define IDS_DRIVE_FIXED
Definition: shresdef.h:105
#define IDS_DRIVE_NETWORK
Definition: shresdef.h:107
#define IDS_DRIVE_FLOPPY
Definition: shresdef.h:108

Definition at line 49 of file CDrivesFolder.cpp.

Referenced by CDrivesFolder::GetDetailsOf().

◆ MyComputerSFHeader