ReactOS 0.4.15-dev-8241-g63935f8
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
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (shell)
 
BOOL _ILGetDriveType (LPCITEMIDLIST pidl)
 
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)
 
static HRESULT getLabelForDrive (LPWSTR wszPath, LPWSTR wszLabel)
 
BOOL IsDriveFloppyA (LPCSTR pszDriveRoot)
 
HRESULT CDrivesExtractIcon_CreateInstance (IShellFolder *psf, LPCITEMIDLIST pidl, REFIID riid, LPVOID *ppvOut)
 

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

◆ RETRY_COUNT

#define RETRY_COUNT   3

Definition at line 73 of file CDrivesFolder.cpp.

◆ RETRY_SLEEP

#define RETRY_SLEEP   250

Definition at line 74 of file CDrivesFolder.cpp.

Function Documentation

◆ _ILGetDriveType()

BOOL _ILGetDriveType ( LPCITEMIDLIST  pidl)

Definition at line 58 of file CDrivesFolder.cpp.

59{
60 WCHAR szDrive[8];
61 if (!_ILGetDrive(pidl, szDrive, _countof(szDrive)))
62 {
63 ERR("pidl %p is not a drive\n", pidl);
64 return DRIVE_UNKNOWN;
65 }
66 return ::GetDriveTypeW(szDrive);
67}
#define ERR(fmt,...)
Definition: debug.h:113
DWORD _ILGetDrive(LPCITEMIDLIST pidl, LPWSTR pOut, UINT uSize)
Definition: pidl.c:1894
#define _countof(array)
Definition: sndvol32.h:70
#define DRIVE_UNKNOWN
Definition: winbase.h:256
__wchar_t WCHAR
Definition: xmlstorage.h:180

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 420 of file CDrivesFolder.cpp.

426{
427 HKEY hKeys[2];
428 UINT cKeys = 0;
429 AddClassKeyToArray(L"Drive", hKeys, &cKeys);
430 AddClassKeyToArray(L"Folder", hKeys, &cKeys);
431
432 return CDefFolderMenu_Create2(pidlFolder, hwnd, cidl, apidl, psf, DrivesContextMenuCallback, cKeys, hKeys, ppcm);
433}
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)
HRESULT CALLBACK DrivesContextMenuCallback(IShellFolder *psf, HWND hwnd, IDataObject *pdtobj, UINT uMsg, WPARAM wParam, LPARAM lParam)
unsigned int UINT
Definition: ndis.h:50
#define L(x)
Definition: ntvdm.h:50
LSTATUS AddClassKeyToArray(const WCHAR *szClass, HKEY *array, UINT *cKeys)
Definition: shlfolder.cpp:277
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023

Referenced by CDrivesFolder::GetUIObjectOf().

◆ CDrivesExtractIcon_CreateInstance()

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

Definition at line 502 of file CDrivesFolder.cpp.

503{
504 CComPtr<IDefaultExtractIconInit> initIcon;
507 return hr;
508
509 CHAR* pszDrive = _ILGetDataPointer(pidl)->u.drive.szDriveName;
510 UINT DriveType = GetDriveTypeA(pszDrive);
513
514 WCHAR wTemp[MAX_PATH];
515 int icon_idx, reg_idx;
516 UINT flags = 0;
517
518 switch (DriveType)
519 {
520 case DRIVE_FIXED:
521 case DRIVE_UNKNOWN:
522 reg_idx = IDI_SHELL_DRIVE;
523 break;
524 case DRIVE_CDROM:
525 reg_idx = IDI_SHELL_CDROM;
526 break;
527 case DRIVE_REMOTE:
528 reg_idx = IDI_SHELL_NETDRIVE;
529 break;
530 case DRIVE_REMOVABLE:
531 if (!IsDriveFloppyA(pszDrive))
532 reg_idx = IDI_SHELL_REMOVEABLE;
533 else
534 reg_idx = IDI_SHELL_3_14_FLOPPY;
535 break;
536 case DRIVE_RAMDISK:
537 reg_idx = IDI_SHELL_RAMDISK;
538 break;
540 default:
541 reg_idx = IDI_SHELL_DOCUMENT;
542 break;
543 }
544
545 hr = getIconLocationForDrive(psf, pidl, 0, wTemp, _countof(wTemp),
546 &icon_idx, &flags);
547 if (SUCCEEDED(hr))
548 {
549 initIcon->SetNormalIcon(wTemp, icon_idx);
550 }
551 else if (HLM_GetIconW(reg_idx - 1, wTemp, _countof(wTemp), &icon_idx))
552 {
553 initIcon->SetNormalIcon(wTemp, icon_idx);
554 }
555 else if ((DriveType == DRIVE_FIXED || DriveType == DRIVE_UNKNOWN) &&
556 (HCR_GetIconW(L"Drive", wTemp, NULL, _countof(wTemp), &icon_idx)))
557 {
558 initIcon->SetNormalIcon(wTemp, icon_idx);
559 }
560 else
561 {
562 if (DriveType == DRIVE_REMOVABLE && !IsDriveFloppyA(pszDrive))
563 {
564 icon_idx = IDI_SHELL_REMOVEABLE;
565 }
566 else
567 {
568 icon_idx = iDriveIconIds[DriveType];
569 }
570 initIcon->SetNormalIcon(swShell32Name, -icon_idx);
571 }
572
573 return initIcon->QueryInterface(riid, ppvOut);
574}
static HRESULT getIconLocationForDrive(IShellFolder *psf, PCITEMID_CHILD pidl, UINT uFlags, LPWSTR szIconFile, UINT cchMax, int *piIndex, UINT *pwFlags)
static int iDriveIconIds[7]
BOOL IsDriveFloppyA(LPCSTR pszDriveRoot)
Definition: drvdefext.cpp:386
HRESULT WINAPI SHCreateDefaultExtractIcon(REFIID riid, void **ppv)
UINT DriveType
#define NULL
Definition: types.h:112
#define MAX_PATH
Definition: compat.h:34
#define FAILED_UNEXPECTEDLY(hr)
Definition: precomp.h:121
UINT WINAPI GetDriveTypeA(IN LPCSTR lpRootPathName)
Definition: disk.c:468
WCHAR swShell32Name[MAX_PATH]
Definition: folders.cpp:22
GLbitfield flags
Definition: glext.h:7161
REFIID riid
Definition: atlbase.h:39
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define DRIVE_CDROM
Definition: machpc98.h:119
LPPIDLDATA _ILGetDataPointer(LPCITEMIDLIST pidl)
Definition: pidl.c:2154
BOOL HCR_GetIconW(LPCWSTR szClass, LPWSTR szDest, LPCWSTR szName, DWORD len, int *picon_idx)
Definition: classes.c:291
HRESULT hr
Definition: shlfolder.c:183
#define IDI_SHELL_3_14_FLOPPY
Definition: shresdef.h:562
#define IDI_SHELL_NETDRIVE
Definition: shresdef.h:565
#define IDI_SHELL_DOCUMENT
Definition: shresdef.h:556
#define IDI_SHELL_CDROM
Definition: shresdef.h:567
#define IDI_SHELL_DRIVE
Definition: shresdef.h:564
#define IDI_SHELL_RAMDISK
Definition: shresdef.h:568
#define IDI_SHELL_REMOVEABLE
Definition: shresdef.h:563
#define DRIVE_NO_ROOT_DIR
Definition: winbase.h:257
#define DRIVE_REMOTE
Definition: winbase.h:253
#define DRIVE_RAMDISK
Definition: winbase.h:255
#define DRIVE_FIXED
Definition: winbase.h:252
#define DRIVE_REMOVABLE
Definition: winbase.h:251
#define IID_PPV_ARG(Itype, ppType)
char CHAR
Definition: xmlstorage.h:175

Referenced by CDrivesFolder::GetUIObjectOf().

◆ DoEjectDrive()

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

Definition at line 95 of file CDrivesFolder.cpp.

96{
97 /* GENERIC_WRITE isn't needed for umount */
98 DWORD dwAccessMode = GENERIC_READ;
100
101 HANDLE hDrive = CreateFile(physical, dwAccessMode, dwShareMode, 0, OPEN_EXISTING, 0, NULL);
102 if (hDrive == INVALID_HANDLE_VALUE)
103 return FALSE;
104
105 BOOL bResult, bNeedUnlock = FALSE;
106 DWORD dwBytesReturned, dwError = NO_ERROR;
107 PREVENT_MEDIA_REMOVAL removal;
108 do
109 {
110 bResult = TryToLockOrUnlockDrive(hDrive, TRUE);
111 if (!bResult)
112 {
113 dwError = GetLastError();
114 *pnStringID = IDS_CANTLOCKVOLUME; /* Unable to lock volume */
115 break;
116 }
117 bResult = DeviceIoControl(hDrive, FSCTL_DISMOUNT_VOLUME, NULL, 0, NULL, 0, &dwBytesReturned, NULL);
118 if (!bResult)
119 {
120 dwError = GetLastError();
121 *pnStringID = IDS_CANTDISMOUNTVOLUME; /* Unable to dismount volume */
122 bNeedUnlock = TRUE;
123 break;
124 }
125 removal.PreventMediaRemoval = FALSE;
126 bResult = DeviceIoControl(hDrive, IOCTL_STORAGE_MEDIA_REMOVAL, &removal, sizeof(removal), NULL,
127 0, &dwBytesReturned, NULL);
128 if (!bResult)
129 {
130 *pnStringID = IDS_CANTEJECTMEDIA; /* Unable to eject media */
131 dwError = GetLastError();
132 bNeedUnlock = TRUE;
133 break;
134 }
135 bResult = DeviceIoControl(hDrive, IOCTL_STORAGE_EJECT_MEDIA, NULL, 0, NULL, 0, &dwBytesReturned, NULL);
136 if (!bResult)
137 {
138 *pnStringID = IDS_CANTEJECTMEDIA; /* Unable to eject media */
139 dwError = GetLastError();
140 bNeedUnlock = TRUE;
141 break;
142 }
143 } while (0);
144
145 if (bNeedUnlock)
146 {
148 }
149
150 CloseHandle(hDrive);
151
152 SetLastError(dwError);
153 return bResult;
154}
static BOOL TryToLockOrUnlockDrive(HANDLE hDrive, BOOL bLock)
#define NO_ERROR
Definition: dderror.h:5
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 TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define CloseHandle
Definition: compat.h:739
#define OPEN_EXISTING
Definition: compat.h:775
#define SetLastError(x)
Definition: compat.h:752
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define GENERIC_READ
Definition: compat.h:135
#define FILE_SHARE_READ
Definition: compat.h:136
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define FSCTL_DISMOUNT_VOLUME
Definition: nt_native.h:834
#define IOCTL_STORAGE_EJECT_MEDIA
Definition: ntddstor.h:107
#define IOCTL_STORAGE_MEDIA_REMOVAL
Definition: ntddstor.h:104
#define IDS_CANTDISMOUNTVOLUME
Definition: shresdef.h:150
#define IDS_CANTLOCKVOLUME
Definition: shresdef.h:149
#define IDS_CANTEJECTMEDIA
Definition: shresdef.h:151
BOOLEAN PreventMediaRemoval
Definition: ntddstor.h:343
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define CreateFile
Definition: winbase.h:3749

Referenced by DrivesContextMenuCallback().

◆ DoFormatDrive()

static HRESULT DoFormatDrive ( HWND  hwnd,
UINT  nDriveNumber 
)
static

Definition at line 250 of file CDrivesFolder.cpp.

251{
253 params->nDriveNumber = nDriveNumber;
254
255 // Create thread to avoid locked.
256 unsigned tid;
258 if (hThread == NULL)
259 {
260 delete params;
261 return E_FAIL;
262 }
263
265
266 return S_OK;
267}
static unsigned __stdcall format_drive_thread(void *args)
#define E_FAIL
Definition: ddrawi.h:102
GLenum const GLfloat * params
Definition: glext.h:5645
#define S_OK
Definition: intsafe.h:52
static TfClientId tid
HANDLE hThread
Definition: wizard.c:28
_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)
PVOID HANDLE
Definition: typedefs.h:73

Referenced by DrivesContextMenuCallback().

◆ DrivesContextMenuCallback()

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

Definition at line 269 of file CDrivesFolder.cpp.

275{
276 if (uMsg != DFM_MERGECONTEXTMENU && uMsg != DFM_INVOKECOMMAND)
277 return SHELL32_DefaultContextMenuCallBack(psf, pdtobj, uMsg);
278
279 PIDLIST_ABSOLUTE pidlFolder;
280 PUITEMID_CHILD *apidl;
281 UINT cidl;
282 UINT nDriveType;
284 HRESULT hr = SH_GetApidlFromDataObject(pdtobj, &pidlFolder, &apidl, &cidl);
286 return hr;
287
288 WCHAR szDrive[8] = {0};
289 if (!_ILGetDrive(apidl[0], szDrive, _countof(szDrive)))
290 {
291 ERR("pidl is not a drive\n");
292 SHFree(pidlFolder);
293 _ILFreeaPidl(apidl, cidl);
294 return E_FAIL;
295 }
296 nDriveType = GetDriveTypeW(szDrive);
297 GetVolumeInformationW(szDrive, NULL, 0, NULL, NULL, &dwFlags, NULL, 0);
298
299// custom command IDs
300#if 0 // Disabled until our menu building system is fixed
301#define CMDID_FORMAT 0
302#define CMDID_EJECT 1
303#define CMDID_DISCONNECT 2
304#else
305/* FIXME: These IDs should start from 0, however there is difference
306 * between ours and Windows' menu building systems, which should be fixed. */
307#define CMDID_FORMAT 1
308#define CMDID_EJECT 2
309#define CMDID_DISCONNECT 3
310#endif
311
312 if (uMsg == DFM_MERGECONTEXTMENU)
313 {
314 QCMINFO *pqcminfo = (QCMINFO *)lParam;
315
316 UINT idCmdFirst = pqcminfo->idCmdFirst;
317 UINT idCmd = 0;
318 if (!(dwFlags & FILE_READ_ONLY_VOLUME) && nDriveType != DRIVE_REMOTE)
319 {
320 /* add separator and Format */
321 idCmd = idCmdFirst + CMDID_FORMAT;
322 _InsertMenuItemW(pqcminfo->hmenu, pqcminfo->indexMenu++, TRUE, 0, MFT_SEPARATOR, NULL, 0);
324 }
325 if (nDriveType == DRIVE_REMOVABLE || nDriveType == DRIVE_CDROM)
326 {
327 /* add separator and Eject */
328 idCmd = idCmdFirst + CMDID_EJECT;
329 _InsertMenuItemW(pqcminfo->hmenu, pqcminfo->indexMenu++, TRUE, 0, MFT_SEPARATOR, NULL, 0);
331 }
332 if (nDriveType == DRIVE_REMOTE)
333 {
334 /* add separator and Disconnect */
335 idCmd = idCmdFirst + CMDID_DISCONNECT;
336 _InsertMenuItemW(pqcminfo->hmenu, pqcminfo->indexMenu++, TRUE, 0, MFT_SEPARATOR, NULL, 0);
338 }
339
340 if (idCmd)
341#if 0 // see FIXME above
342 pqcminfo->idCmdFirst = ++idCmd;
343#else
344 pqcminfo->idCmdFirst = (idCmd + 2);
345#endif
346 hr = S_OK;
347 }
348 else if (uMsg == DFM_INVOKECOMMAND)
349 {
350 WCHAR wszBuf[4] = L"A:\\";
351 wszBuf[0] = (WCHAR)szDrive[0];
352
353 INT nStringID = 0;
354 DWORD dwError = NO_ERROR;
355
357 {
358 // pdtobj should be valid at this point!
359 ATLASSERT(pdtobj);
360 hr = SH_ShowDriveProperties(wszBuf, pdtobj) ? S_OK : E_UNEXPECTED;
361 if (FAILED(hr))
362 {
363 dwError = ERROR_CAN_NOT_COMPLETE;
364 nStringID = IDS_CANTSHOWPROPERTIES;
365 }
366 }
367 else
368 {
369 if (wParam == CMDID_FORMAT)
370 {
371 hr = DoFormatDrive(hwnd, szDrive[0] - 'A');
372 }
373 else if (wParam == CMDID_EJECT)
374 {
375 /* do eject */
376 WCHAR physical[10];
377 wsprintfW(physical, _T("\\\\.\\%c:"), szDrive[0]);
378
379 if (DoEjectDrive(physical, nDriveType, &nStringID))
380 {
382 }
383 else
384 {
385 dwError = GetLastError();
386 }
387 }
388 else if (wParam == CMDID_DISCONNECT)
389 {
390 /* do disconnect */
391 wszBuf[2] = UNICODE_NULL;
392 dwError = WNetCancelConnection2W(wszBuf, 0, FALSE);
393 if (dwError == NO_ERROR)
394 {
396 }
397 else
398 {
399 nStringID = IDS_CANTDISCONNECT;
400 }
401 }
402 }
403
404 if (nStringID != 0)
405 {
406 /* show error message */
407 WCHAR szFormat[128], szMessage[128];
408 LoadStringW(shell32_hInstance, nStringID, szFormat, _countof(szFormat));
409 wsprintfW(szMessage, szFormat, dwError);
410 MessageBoxW(hwnd, szMessage, NULL, MB_ICONERROR);
411 }
412 }
413
414 SHFree(pidlFolder);
415 _ILFreeaPidl(apidl, cidl);
416
417 return hr;
418}
#define ATLASSERT(x)
Definition: CComVariant.cpp:10
#define CMDID_FORMAT
static HRESULT DoFormatDrive(HWND hwnd, UINT nDriveNumber)
static BOOL DoEjectDrive(const WCHAR *physical, UINT nDriveType, INT *pnStringID)
#define CMDID_EJECT
#define CMDID_DISCONNECT
#define shell32_hInstance
EXTERN_C void WINAPI SHChangeNotify(LONG wEventId, UINT uFlags, LPCVOID dwItem1, LPCVOID dwItem2)
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define DFM_MERGECONTEXTMENU
Definition: precomp.h:44
#define DFM_INVOKECOMMAND
Definition: precomp.h:45
UINT WINAPI GetDriveTypeW(IN LPCWSTR lpRootPathName)
Definition: disk.c:497
BOOL WINAPI GetVolumeInformationW(IN LPCWSTR lpRootPathName, IN LPWSTR lpVolumeNameBuffer, IN DWORD nVolumeNameSize, OUT LPDWORD lpVolumeSerialNumber OPTIONAL, OUT LPDWORD lpMaximumComponentLength OPTIONAL, OUT LPDWORD lpFileSystemFlags OPTIONAL, OUT LPWSTR lpFileSystemNameBuffer OPTIONAL, IN DWORD nFileSystemNameSize)
Definition: volume.c:226
HRESULT SHELL32_DefaultContextMenuCallBack(IShellFolder *psf, IDataObject *pdo, UINT msg)
Definition: shlfolder.cpp:522
void WINAPI SHFree(LPVOID pv)
Definition: shellole.c:326
BOOL SH_ShowDriveProperties(WCHAR *pwszDrive, IDataObject *pDataObj)
Definition: drive.cpp:170
#define FILE_READ_ONLY_VOLUME
Definition: from_kernel.h:246
#define FAILED(hr)
Definition: intsafe.h:51
#define UNICODE_NULL
void _ILFreeaPidl(LPITEMIDLIST *apidl, UINT cidl)
Definition: pidl.c:2594
HRESULT SH_GetApidlFromDataObject(IDataObject *pDataObject, PIDLIST_ABSOLUTE *ppidlfolder, PUITEMID_CHILD **apidlItems, UINT *pcidl)
Definition: shlfolder.cpp:368
void WINAPI _InsertMenuItemW(HMENU hmenu, UINT indexMenu, BOOL fByPosition, UINT wID, UINT fType, LPCWSTR dwTypeData, UINT fState)
#define SHCNE_DRIVEREMOVED
Definition: shlobj.h:1890
#define SHCNE_MEDIAREMOVED
Definition: shlobj.h:1889
#define SHCNF_PATHW
Definition: shlobj.h:1918
#define DFM_CMD_PROPERTIES
Definition: shlobj.h:2605
#define SHCNF_FLUSHNOWAIT
Definition: shlobj.h:1922
#define IDS_DISCONNECT
Definition: shresdef.h:247
#define IDS_EJECT
Definition: shresdef.h:246
#define IDS_CANTSHOWPROPERTIES
Definition: shresdef.h:152
#define IDS_CANTDISCONNECT
Definition: shresdef.h:153
#define IDS_FORMATDRIVE
Definition: shresdef.h:232
ITEMID_CHILD UNALIGNED * PUITEMID_CHILD
Definition: shtypes.idl:68
HMENU hmenu
Definition: shlobj.h:1389
UINT idCmdFirst
Definition: shlobj.h:1391
UINT indexMenu
Definition: shlobj.h:1390
int32_t INT
Definition: typedefs.h:58
#define _T(x)
Definition: vfdio.h:22
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176
#define E_UNEXPECTED
Definition: winerror.h:2456
#define ERROR_CAN_NOT_COMPLETE
Definition: winerror.h:582
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
int WINAPIV wsprintfW(_Out_ LPWSTR, _In_ _Printf_format_string_ LPCWSTR,...)
#define MFT_SEPARATOR
Definition: winuser.h:744
int WINAPI MessageBoxW(_In_opt_ HWND hWnd, _In_opt_ LPCWSTR lpText, _In_opt_ LPCWSTR lpCaption, _In_ UINT uType)
#define MB_ICONERROR
Definition: winuser.h:787
#define MFS_ENABLED
Definition: winuser.h:750
#define MFT_STRING
Definition: winuser.h:746
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
DWORD WINAPI WNetCancelConnection2W(LPCWSTR lpName, DWORD dwFlags, BOOL fForce)
Definition: wnet.c:2420

Referenced by CDrivesContextMenu_CreateInstance().

◆ EnumStubProc()

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

Definition at line 158 of file CDrivesFolder.cpp.

159{
160 CSimpleArray<HWND> *pStubs = reinterpret_cast<CSimpleArray<HWND> *>(lParam);
161
162 WCHAR szClass[64];
163 GetClassNameW(hwnd, szClass, _countof(szClass));
164
165 if (lstrcmpiW(szClass, L"StubWindow32") == 0)
166 {
167 pStubs->Add(hwnd);
168 }
169
170 return TRUE;
171}
int WINAPI lstrcmpiW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4261
int WINAPI GetClassNameW(_In_ HWND hWnd, _Out_writes_to_(nMaxCount, return) LPWSTR lpClassName, _In_ int nMaxCount)

Referenced by format_drive_thread().

◆ EnumStubProc2()

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

Definition at line 175 of file CDrivesFolder.cpp.

176{
177 HWND *phwnd = reinterpret_cast<HWND *>(lParam);
178
179 if (phwnd[0] == GetWindow(hwnd, GW_OWNER))
180 {
181 phwnd[1] = hwnd;
182 return FALSE;
183 }
184
185 return TRUE;
186}
#define GW_OWNER
Definition: winuser.h:766
HWND WINAPI GetWindow(_In_ HWND, _In_ UINT)

Referenced by format_drive_thread().

◆ format_drive_thread()

static unsigned __stdcall format_drive_thread ( void args)
static

Definition at line 194 of file CDrivesFolder.cpp.

195{
197 UINT nDriveNumber = params->nDriveNumber;
198 LONG_PTR nProp = nDriveNumber | 0x7F00;
199
200 // Search the stub windows that already exist.
201 CSimpleArray<HWND> old_stubs;
202 EnumWindows(EnumStubProc, (LPARAM)&old_stubs);
203
204 for (INT n = 0; n < old_stubs.GetSize(); ++n)
205 {
206 HWND hwndStub = old_stubs[n];
207
208 // The target stub window has the prop.
209 if (GetPropW(hwndStub, L"DriveNumber") == (HANDLE)nProp)
210 {
211 // Found.
212 HWND ahwnd[2];
213 ahwnd[0] = hwndStub;
214 ahwnd[1] = NULL;
216
217 // Activate.
218 BringWindowToTop(ahwnd[1]);
219
220 delete params;
221 return 0;
222 }
223 }
224
225 // Create a stub window.
229 if (!stub.Create(NULL, NULL, NULL, style, exstyle))
230 {
231 ERR("StubWindow32 creation failed\n");
232 delete params;
233 return 0;
234 }
235
236 // Add prop to the target stub window.
237 SetPropW(stub, L"DriveNumber", (HANDLE)nProp);
238
239 // Do format.
240 SHFormatDrive(stub, nDriveNumber, SHFMT_ID_DEFAULT, 0);
241
242 // Clean up.
243 RemovePropW(stub, L"DriveNumber");
244 stub.DestroyWindow();
245 delete params;
246
247 return 0;
248}
static BOOL CALLBACK EnumStubProc2(HWND hwnd, LPARAM lParam)
static BOOL CALLBACK EnumStubProc(HWND hwnd, LPARAM lParam)
Arabic default style
Definition: afstyles.h:94
DWORD WINAPI SHFormatDrive(HWND hwnd, UINT drive, UINT fmtID, UINT options)
Definition: drive.cpp:699
GLdouble n
Definition: glext.h:7729
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define WS_CAPTION
Definition: pedump.c:624
#define WS_DISABLED
Definition: pedump.c:621
#define WS_CLIPSIBLINGS
Definition: pedump.c:618
#define SHFMT_ID_DEFAULT
Definition: shlobj.h:332
Definition: stubgen.c:11
Definition: match.c:390
struct _stub stub
LONG_PTR LPARAM
Definition: windef.h:208
HANDLE WINAPI RemovePropW(_In_ HWND, _In_ LPCWSTR)
#define WS_EX_APPWINDOW
Definition: winuser.h:383
BOOL WINAPI EnumWindows(_In_ WNDENUMPROC lpEnumFunc, _In_ LPARAM lParam)
BOOL WINAPI SetPropW(_In_ HWND, _In_ LPCWSTR, _In_opt_ HANDLE)
#define WS_EX_WINDOWEDGE
Definition: winuser.h:407
HANDLE WINAPI GetPropW(_In_ HWND, _In_ LPCWSTR)
BOOL WINAPI BringWindowToTop(_In_ HWND)

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 436 of file CDrivesFolder.cpp.

438{
439 WCHAR wszPath[MAX_PATH];
440 WCHAR wszAutoRunInfPath[MAX_PATH];
441 WCHAR wszValue[MAX_PATH], wszTemp[MAX_PATH];
442
443 // get path
444 if (!ILGetDisplayNameExW(psf, pidl, wszPath, 0))
445 return E_FAIL;
446 if (!PathIsDirectoryW(wszPath))
447 return E_FAIL;
448
449 // build the full path of autorun.inf
450 StringCchCopyW(wszAutoRunInfPath, _countof(wszAutoRunInfPath), wszPath);
451 PathAppendW(wszAutoRunInfPath, L"autorun.inf");
452
453 // autorun.inf --> wszValue
454 if (GetPrivateProfileStringW(L"autorun", L"icon", NULL, wszValue, _countof(wszValue),
455 wszAutoRunInfPath) && wszValue[0] != 0)
456 {
457 // wszValue --> wszTemp
458 ExpandEnvironmentStringsW(wszValue, wszTemp, _countof(wszTemp));
459
460 // parse the icon location
461 *piIndex = PathParseIconLocationW(wszTemp);
462
463 // wszPath + wszTemp --> wszPath
464 if (PathIsRelativeW(wszTemp))
465 PathAppendW(wszPath, wszTemp);
466 else
467 StringCchCopyW(wszPath, _countof(wszPath), wszTemp);
468
469 // wszPath --> szIconFile
470 GetFullPathNameW(wszPath, cchMax, szIconFile, NULL);
471
472 return S_OK;
473 }
474
475 return E_FAIL;
476}
UINT cchMax
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:519
DWORD WINAPI GetFullPathNameW(IN LPCWSTR lpFileName, IN DWORD nBufferLength, OUT LPWSTR lpBuffer, OUT LPWSTR *lpFilePart)
Definition: path.c:1106
INT WINAPI GetPrivateProfileStringW(LPCWSTR section, LPCWSTR entry, LPCWSTR def_val, LPWSTR buffer, UINT len, LPCWSTR filename)
Definition: profile.c:1142
BOOL WINAPI PathIsDirectoryW(LPCWSTR lpszPath)
Definition: path.c:1723
int WINAPI PathParseIconLocationW(LPWSTR lpszPath)
Definition: path.c:1092
BOOL WINAPI PathIsRelativeW(LPCWSTR lpszPath)
Definition: path.c:1579
#define PathAppendW
Definition: pathcch.h:309
BOOL ILGetDisplayNameExW(LPSHELLFOLDER psf, LPCITEMIDLIST pidl, LPWSTR path, DWORD type)
Definition: pidl.c:100
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149

Referenced by CDrivesExtractIcon_CreateInstance().

◆ getLabelForDrive()

static HRESULT getLabelForDrive ( LPWSTR  wszPath,
LPWSTR  wszLabel 
)
static

Definition at line 479 of file CDrivesFolder.cpp.

480{
481 WCHAR wszAutoRunInfPath[MAX_PATH];
482 WCHAR wszTemp[MAX_PATH];
483
484 if (!PathIsDirectoryW(wszPath))
485 return E_FAIL;
486
487 StringCchCopyW(wszAutoRunInfPath, _countof(wszAutoRunInfPath), wszPath);
488 PathAppendW(wszAutoRunInfPath, L"autorun.inf");
489
490 if (GetPrivateProfileStringW(L"autorun", L"label", NULL, wszTemp, _countof(wszTemp),
491 wszAutoRunInfPath) && wszTemp[0] != 0)
492 {
493 StringCchCopyW(wszLabel, _countof(wszTemp), wszTemp);
494 return S_OK;
495 }
496
497 return E_FAIL;
498}

Referenced by CDrivesFolder::GetDisplayNameOf().

◆ IsDriveFloppyA()

BOOL IsDriveFloppyA ( LPCSTR  pszDriveRoot)

Definition at line 386 of file drvdefext.cpp.

387{
388 WCHAR szRoot[8];
389 MultiByteToWideChar(CP_ACP, 0, pszDriveRoot, -1, szRoot, _countof(szRoot));
390 return IsDriveFloppyW(szRoot);
391}
#define CP_ACP
Definition: compat.h:109
#define MultiByteToWideChar
Definition: compat.h:110
BOOL IsDriveFloppyW(LPCWSTR pszDriveRoot)
Definition: drvdefext.cpp:320

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

◆ TryToLockOrUnlockDrive()

static BOOL TryToLockOrUnlockDrive ( HANDLE  hDrive,
BOOL  bLock 
)
static

Definition at line 75 of file CDrivesFolder.cpp.

76{
77 DWORD dwError, dwBytesReturned;
78 DWORD dwCode = (bLock ? FSCTL_LOCK_VOLUME : FSCTL_UNLOCK_VOLUME);
79 for (DWORD i = 0; i < RETRY_COUNT; ++i)
80 {
81 if (DeviceIoControl(hDrive, dwCode, NULL, 0, NULL, 0, &dwBytesReturned, NULL))
82 return TRUE;
83
84 dwError = GetLastError();
85 if (dwError == ERROR_INVALID_FUNCTION)
86 break; /* don't sleep if function is not implemented */
87
89 }
90 SetLastError(dwError);
91 return FALSE;
92}
#define RETRY_COUNT
#define RETRY_SLEEP
#define ERROR_INVALID_FUNCTION
Definition: dderror.h:6
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
#define FSCTL_LOCK_VOLUME
Definition: nt_native.h:832
#define FSCTL_UNLOCK_VOLUME
Definition: nt_native.h:833
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790

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 620 of file CDrivesFolder.cpp.

Referenced by CDrivesFolder::GetAttributesOf().

◆ dwControlPanelAttributes

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

Definition at line 623 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 625 of file CDrivesFolder.cpp.

Referenced by CDrivesFolder::GetAttributesOf().

◆ iDriveIconIds

◆ iDriveTypeIds

int iDriveTypeIds[7]
static
Initial value:
}
#define IDS_DRIVE_CDROM
Definition: shresdef.h:114
#define IDS_DRIVE_FIXED
Definition: shresdef.h:113
#define IDS_DRIVE_NETWORK
Definition: shresdef.h:115
#define IDS_DRIVE_FLOPPY
Definition: shresdef.h:116

Definition at line 49 of file CDrivesFolder.cpp.

Referenced by CDrivesFolder::GetDetailsOf().

◆ MyComputerSFHeader

const shvheader MyComputerSFHeader[]
static