ReactOS 0.4.16-dev-814-g656a5dc
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

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)
 
static const CLSIDIsRegItem (PCUITEMID_CHILD pidl)
 
BOOL _ILGetDriveType (LPCITEMIDLIST pidl)
 
BOOL SHELL32_IsShellFolderNamespaceItemHidden (LPCWSTR SubKey, REFCLSID Clsid)
 
static BOOL TryToLockOrUnlockDrive (HANDLE hDrive, BOOL bLock)
 
static BOOL DoEjectDrive (const WCHAR *physical, UINT nDriveType, INT *pnStringID)
 
static DWORD CALLBACK DoFormatDriveThread (LPVOID args)
 
static HRESULT DoFormatDriveAsync (HWND hwnd, UINT nDrive)
 
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 REQUIREDREGITEM g_RequiredItems []
 
static const REGFOLDERINFO g_RegFolderInfo
 
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 106 of file CDrivesFolder.cpp.

◆ RETRY_SLEEP

#define RETRY_SLEEP   250

Definition at line 107 of file CDrivesFolder.cpp.

Function Documentation

◆ _ILGetDriveType()

BOOL _ILGetDriveType ( LPCITEMIDLIST  pidl)

Definition at line 81 of file CDrivesFolder.cpp.

82{
83 WCHAR szDrive[8];
84 if (!_ILGetDrive(pidl, szDrive, _countof(szDrive)))
85 {
86 ERR("pidl %p is not a drive\n", pidl);
87 return DRIVE_UNKNOWN;
88 }
89 return ::GetDriveTypeW(szDrive);
90}
#define ERR(fmt,...)
Definition: precomp.h:57
DWORD _ILGetDrive(LPCITEMIDLIST pidl, LPWSTR pOut, UINT uSize)
Definition: pidl.c:2006
#define _countof(array)
Definition: sndvol32.h:70
#define DRIVE_UNKNOWN
Definition: winbase.h:282
__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 353 of file CDrivesFolder.cpp.

359{
360 HKEY hKeys[2];
361 UINT cKeys = 0;
362 AddClassKeyToArray(L"Drive", hKeys, &cKeys);
363 AddClassKeyToArray(L"Folder", hKeys, &cKeys);
364
365 return CDefFolderMenu_Create2(pidlFolder, hwnd, cidl, apidl, psf, DrivesContextMenuCallback, cKeys, hKeys, ppcm);
366}
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:311
_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 435 of file CDrivesFolder.cpp.

436{
437 CComPtr<IDefaultExtractIconInit> initIcon;
440 return hr;
441
442 CHAR* pszDrive = _ILGetDataPointer(pidl)->u.drive.szDriveName;
443 UINT DriveType = GetDriveTypeA(pszDrive);
446
447 WCHAR wTemp[MAX_PATH];
448 int icon_idx, reg_idx;
449 UINT flags = 0;
450
451 switch (DriveType)
452 {
453 case DRIVE_FIXED:
454 case DRIVE_UNKNOWN:
455 reg_idx = IDI_SHELL_DRIVE;
456 break;
457 case DRIVE_CDROM:
458 reg_idx = IDI_SHELL_CDROM;
459 break;
460 case DRIVE_REMOTE:
461 reg_idx = IDI_SHELL_NETDRIVE;
462 break;
463 case DRIVE_REMOVABLE:
464 if (!IsDriveFloppyA(pszDrive))
465 reg_idx = IDI_SHELL_REMOVEABLE;
466 else
467 reg_idx = IDI_SHELL_3_14_FLOPPY;
468 break;
469 case DRIVE_RAMDISK:
470 reg_idx = IDI_SHELL_RAMDISK;
471 break;
473 default:
474 reg_idx = IDI_SHELL_DOCUMENT;
475 break;
476 }
477
478 hr = getIconLocationForDrive(psf, pidl, 0, wTemp, _countof(wTemp),
479 &icon_idx, &flags);
480 if (SUCCEEDED(hr))
481 {
482 initIcon->SetNormalIcon(wTemp, icon_idx);
483 }
484 else if (HLM_GetIconW(reg_idx - 1, wTemp, _countof(wTemp), &icon_idx))
485 {
486 initIcon->SetNormalIcon(wTemp, icon_idx);
487 }
488 else if ((DriveType == DRIVE_FIXED || DriveType == DRIVE_UNKNOWN) &&
489 (HCR_GetIconW(L"Drive", wTemp, NULL, _countof(wTemp), &icon_idx)))
490 {
491 initIcon->SetNormalIcon(wTemp, icon_idx);
492 }
493 else
494 {
495 if (DriveType == DRIVE_REMOVABLE && !IsDriveFloppyA(pszDrive))
496 {
497 icon_idx = IDI_SHELL_REMOVEABLE;
498 }
499 else
500 {
501 icon_idx = iDriveIconIds[DriveType];
502 }
503 initIcon->SetNormalIcon(swShell32Name, -icon_idx);
504 }
505
506 return initIcon->QueryInterface(riid, ppvOut);
507}
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:2254
BOOL HCR_GetIconW(LPCWSTR szClass, LPWSTR szDest, LPCWSTR szName, DWORD len, int *picon_idx)
Definition: classes.c:314
HRESULT hr
Definition: shlfolder.c:183
#define IDI_SHELL_3_14_FLOPPY
Definition: shresdef.h:563
#define IDI_SHELL_NETDRIVE
Definition: shresdef.h:566
#define IDI_SHELL_DOCUMENT
Definition: shresdef.h:557
#define IDI_SHELL_CDROM
Definition: shresdef.h:568
#define IDI_SHELL_DRIVE
Definition: shresdef.h:565
#define IDI_SHELL_RAMDISK
Definition: shresdef.h:569
#define IDI_SHELL_REMOVEABLE
Definition: shresdef.h:564
struct tagDriveStruct drive
Definition: pidl.h:210
union tagPIDLDATA::@565 u
#define DRIVE_NO_ROOT_DIR
Definition: winbase.h:283
#define DRIVE_REMOTE
Definition: winbase.h:279
#define DRIVE_RAMDISK
Definition: winbase.h:281
#define DRIVE_FIXED
Definition: winbase.h:278
#define DRIVE_REMOVABLE
Definition: winbase.h:277
#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 128 of file CDrivesFolder.cpp.

129{
130 /* GENERIC_WRITE isn't needed for umount */
131 DWORD dwAccessMode = GENERIC_READ;
132 DWORD dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;
133
134 HANDLE hDrive = CreateFile(physical, dwAccessMode, dwShareMode, 0, OPEN_EXISTING, 0, NULL);
135 if (hDrive == INVALID_HANDLE_VALUE)
136 return FALSE;
137
138 BOOL bResult, bNeedUnlock = FALSE;
139 DWORD dwBytesReturned, dwError = NO_ERROR;
140 PREVENT_MEDIA_REMOVAL removal;
141 do
142 {
143 bResult = TryToLockOrUnlockDrive(hDrive, TRUE);
144 if (!bResult)
145 {
146 dwError = GetLastError();
147 *pnStringID = IDS_CANTLOCKVOLUME; /* Unable to lock volume */
148 break;
149 }
150 bResult = DeviceIoControl(hDrive, FSCTL_DISMOUNT_VOLUME, NULL, 0, NULL, 0, &dwBytesReturned, NULL);
151 if (!bResult)
152 {
153 dwError = GetLastError();
154 *pnStringID = IDS_CANTDISMOUNTVOLUME; /* Unable to dismount volume */
155 bNeedUnlock = TRUE;
156 break;
157 }
158 removal.PreventMediaRemoval = FALSE;
159 bResult = DeviceIoControl(hDrive, IOCTL_STORAGE_MEDIA_REMOVAL, &removal, sizeof(removal), NULL,
160 0, &dwBytesReturned, NULL);
161 if (!bResult)
162 {
163 *pnStringID = IDS_CANTEJECTMEDIA; /* Unable to eject media */
164 dwError = GetLastError();
165 bNeedUnlock = TRUE;
166 break;
167 }
168 bResult = DeviceIoControl(hDrive, IOCTL_STORAGE_EJECT_MEDIA, NULL, 0, NULL, 0, &dwBytesReturned, NULL);
169 if (!bResult)
170 {
171 *pnStringID = IDS_CANTEJECTMEDIA; /* Unable to eject media */
172 dwError = GetLastError();
173 bNeedUnlock = TRUE;
174 break;
175 }
176 } while (0);
177
178 if (bNeedUnlock)
179 {
181 }
182
183 CloseHandle(hDrive);
184
185 SetLastError(dwError);
186 return bResult;
187}
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:148
#define IDS_CANTLOCKVOLUME
Definition: shresdef.h:147
#define IDS_CANTEJECTMEDIA
Definition: shresdef.h:149
BOOLEAN PreventMediaRemoval
Definition: ntddstor.h:343
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define CreateFile
Definition: winbase.h:3774

Referenced by DrivesContextMenuCallback().

◆ DoFormatDriveAsync()

static HRESULT DoFormatDriveAsync ( HWND  hwnd,
UINT  nDrive 
)
static

Definition at line 201 of file CDrivesFolder.cpp.

202{
204 return succ ? S_OK : E_FAIL;
205}
static DWORD CALLBACK DoFormatDriveThread(LPVOID args)
#define E_FAIL
Definition: ddrawi.h:102
BOOL WINAPI SHCreateThread(LPTHREAD_START_ROUTINE pfnThreadProc, VOID *pData, DWORD dwFlags, LPTHREAD_START_ROUTINE pfnCallback)
Definition: thread.c:356
#define UlongToPtr(u)
Definition: config.h:106
#define S_OK
Definition: intsafe.h:52
#define CTF_PROCESS_REF
Definition: shlwapi.h:1963

Referenced by DrivesContextMenuCallback().

◆ DoFormatDriveThread()

static DWORD CALLBACK DoFormatDriveThread ( LPVOID  args)
static

Definition at line 189 of file CDrivesFolder.cpp.

190{
191 UINT nDrive = PtrToUlong(args);
192 WCHAR szPath[] = { LOWORD(L'A' + nDrive), L'\0' }; // Arbitrary, just needs to include nDrive
195 if (FAILED(hr))
196 return hr;
198 return stub.DestroyWindow();
199}
@ TYPE_FORMATDRIVE
Definition: precomp.h:205
DWORD WINAPI SHFormatDrive(HWND hwnd, UINT drive, UINT fmtID, UINT options)
Definition: drive.cpp:621
#define PtrToUlong(u)
Definition: config.h:107
#define FAILED(hr)
Definition: intsafe.h:51
LPCWSTR szPath
Definition: env.c:37
#define LOWORD(l)
Definition: pedump.c:82
#define SHFMT_ID_DEFAULT
Definition: shlobj.h:332
Definition: stubgen.c:11
Definition: match.c:390
struct _stub stub

Referenced by DoFormatDriveAsync().

◆ DrivesContextMenuCallback()

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

Definition at line 207 of file CDrivesFolder.cpp.

213{
214 if (uMsg != DFM_MERGECONTEXTMENU && uMsg != DFM_INVOKECOMMAND)
215 return SHELL32_DefaultContextMenuCallBack(psf, pdtobj, uMsg);
216
217 PIDLIST_ABSOLUTE pidlFolder;
218 PUITEMID_CHILD *apidl;
219 UINT cidl;
220 UINT nDriveType;
222 HRESULT hr = SH_GetApidlFromDataObject(pdtobj, &pidlFolder, &apidl, &cidl);
224 return hr;
225
226 WCHAR szDrive[8] = {0};
227 if (!_ILGetDrive(apidl[0], szDrive, _countof(szDrive)))
228 {
229 ERR("pidl is not a drive\n");
230 SHFree(pidlFolder);
231 _ILFreeaPidl(apidl, cidl);
232 return E_FAIL;
233 }
234 nDriveType = GetDriveTypeW(szDrive);
235 GetVolumeInformationW(szDrive, NULL, 0, NULL, NULL, &dwFlags, NULL, 0);
236
237// custom command IDs
238#if 0 // Disabled until our menu building system is fixed
239#define CMDID_FORMAT 0
240#define CMDID_EJECT 1
241#define CMDID_DISCONNECT 2
242#else
243/* FIXME: These IDs should start from 0, however there is difference
244 * between ours and Windows' menu building systems, which should be fixed. */
245#define CMDID_FORMAT 1
246#define CMDID_EJECT 2
247#define CMDID_DISCONNECT 3
248#endif
249
250 if (uMsg == DFM_MERGECONTEXTMENU)
251 {
252 QCMINFO *pqcminfo = (QCMINFO *)lParam;
253
254 UINT idCmdFirst = pqcminfo->idCmdFirst;
255 UINT idCmd = 0;
256 if (!(dwFlags & FILE_READ_ONLY_VOLUME) && nDriveType != DRIVE_REMOTE)
257 {
258 /* add separator and Format */
259 idCmd = idCmdFirst + CMDID_FORMAT;
260 _InsertMenuItemW(pqcminfo->hmenu, pqcminfo->indexMenu++, TRUE, 0, MFT_SEPARATOR, NULL, 0);
262 }
263 if (nDriveType == DRIVE_REMOVABLE || nDriveType == DRIVE_CDROM)
264 {
265 /* add separator and Eject */
266 idCmd = idCmdFirst + CMDID_EJECT;
267 _InsertMenuItemW(pqcminfo->hmenu, pqcminfo->indexMenu++, TRUE, 0, MFT_SEPARATOR, NULL, 0);
269 }
270 if (nDriveType == DRIVE_REMOTE)
271 {
272 /* add separator and Disconnect */
273 idCmd = idCmdFirst + CMDID_DISCONNECT;
274 _InsertMenuItemW(pqcminfo->hmenu, pqcminfo->indexMenu++, TRUE, 0, MFT_SEPARATOR, NULL, 0);
276 }
277
278 if (idCmd)
279#if 0 // see FIXME above
280 pqcminfo->idCmdFirst = ++idCmd;
281#else
282 pqcminfo->idCmdFirst = (idCmd + 2);
283#endif
284 hr = S_OK;
285 }
286 else if (uMsg == DFM_INVOKECOMMAND)
287 {
288 WCHAR wszBuf[4] = L"A:\\";
289 wszBuf[0] = (WCHAR)szDrive[0];
290
291 INT nStringID = 0;
292 DWORD dwError = NO_ERROR;
293
295 {
296 ATLASSERT(pdtobj);
298 // Not setting nStringID because SHOpenPropSheet already displayed an error box
299 }
300 else
301 {
302 if (wParam == CMDID_FORMAT)
303 {
304 hr = DoFormatDriveAsync(hwnd, szDrive[0] - 'A');
305 }
306 else if (wParam == CMDID_EJECT)
307 {
308 /* do eject */
309 WCHAR physical[10];
310 wsprintfW(physical, _T("\\\\.\\%c:"), szDrive[0]);
311
312 if (DoEjectDrive(physical, nDriveType, &nStringID))
313 {
315 }
316 else
317 {
318 dwError = GetLastError();
319 }
320 }
321 else if (wParam == CMDID_DISCONNECT)
322 {
323 /* do disconnect */
324 wszBuf[2] = UNICODE_NULL;
325 dwError = WNetCancelConnection2W(wszBuf, 0, FALSE);
326 if (dwError == NO_ERROR)
327 {
329 }
330 else
331 {
332 nStringID = IDS_CANTDISCONNECT;
333 }
334 }
335 }
336
337 if (nStringID != 0)
338 {
339 /* show error message */
340 WCHAR szFormat[128], szMessage[128];
341 LoadStringW(shell32_hInstance, nStringID, szFormat, _countof(szFormat));
342 wsprintfW(szMessage, szFormat, dwError);
343 MessageBoxW(hwnd, szMessage, NULL, MB_ICONERROR);
344 }
345 }
346
347 SHFree(pidlFolder);
348 _ILFreeaPidl(apidl, cidl);
349
350 return hr;
351}
#define ATLASSERT(x)
Definition: CComVariant.cpp:10
static HRESULT DoFormatDriveAsync(HWND hwnd, UINT nDrive)
#define CMDID_FORMAT
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:525
void WINAPI SHFree(LPVOID pv)
Definition: shellole.c:326
#define FILE_READ_ONLY_VOLUME
Definition: from_kernel.h:246
HRESULT SHELL32_ShowFilesystemItemPropertiesDialogAsync(IDataObject *pDO)
Definition: item_prop.cpp:146
#define UNICODE_NULL
void _ILFreeaPidl(LPITEMIDLIST *apidl, UINT cidl)
Definition: pidl.c:2603
HRESULT SH_GetApidlFromDataObject(IDataObject *pDataObject, PIDLIST_ABSOLUTE *ppidlfolder, PUITEMID_CHILD **apidlItems, UINT *pcidl)
Definition: shlfolder.cpp:402
void WINAPI _InsertMenuItemW(HMENU hmenu, UINT indexMenu, BOOL fByPosition, UINT wID, UINT fType, LPCWSTR dwTypeData, UINT fState)
#define SHCNE_DRIVEREMOVED
Definition: shlobj.h:1897
#define SHCNE_MEDIAREMOVED
Definition: shlobj.h:1896
#define SHCNF_PATHW
Definition: shlobj.h:1925
#define DFM_CMD_PROPERTIES
Definition: shlobj.h:2612
#define SHCNF_FLUSHNOWAIT
Definition: shlobj.h:1929
#define IDS_DISCONNECT
Definition: shresdef.h:244
#define IDS_EJECT
Definition: shresdef.h:243
#define IDS_CANTDISCONNECT
Definition: shresdef.h:151
#define IDS_FORMATDRIVE
Definition: shresdef.h:229
ITEMID_CHILD UNALIGNED * PUITEMID_CHILD
Definition: shtypes.idl:68
HMENU hmenu
Definition: shlobj.h:1390
UINT idCmdFirst
Definition: shlobj.h:1392
UINT indexMenu
Definition: shlobj.h:1391
int32_t INT
Definition: typedefs.h:58
#define _T(x)
Definition: vfdio.h:22
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176
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:747
int WINAPI MessageBoxW(_In_opt_ HWND hWnd, _In_opt_ LPCWSTR lpText, _In_opt_ LPCWSTR lpCaption, _In_ UINT uType)
#define MB_ICONERROR
Definition: winuser.h:790
#define MFS_ENABLED
Definition: winuser.h:753
#define MFT_STRING
Definition: winuser.h:749
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
DWORD WINAPI WNetCancelConnection2W(LPCWSTR lpName, DWORD dwFlags, BOOL fForce)
Definition: wnet.c:2420

Referenced by CDrivesContextMenu_CreateInstance().

◆ getIconLocationForDrive()

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

Definition at line 369 of file CDrivesFolder.cpp.

371{
372 WCHAR wszPath[MAX_PATH];
373 WCHAR wszAutoRunInfPath[MAX_PATH];
374 WCHAR wszValue[MAX_PATH], wszTemp[MAX_PATH];
375
376 // get path
377 if (!ILGetDisplayNameExW(psf, pidl, wszPath, 0))
378 return E_FAIL;
379 if (!PathIsDirectoryW(wszPath))
380 return E_FAIL;
381
382 // build the full path of autorun.inf
383 StringCchCopyW(wszAutoRunInfPath, _countof(wszAutoRunInfPath), wszPath);
384 PathAppendW(wszAutoRunInfPath, L"autorun.inf");
385
386 // autorun.inf --> wszValue
387 if (GetPrivateProfileStringW(L"autorun", L"icon", NULL, wszValue, _countof(wszValue),
388 wszAutoRunInfPath) && wszValue[0] != 0)
389 {
390 // wszValue --> wszTemp
391 ExpandEnvironmentStringsW(wszValue, wszTemp, _countof(wszTemp));
392
393 // parse the icon location
394 *piIndex = PathParseIconLocationW(wszTemp);
395
396 // wszPath + wszTemp --> wszPath
397 if (PathIsRelativeW(wszTemp))
398 PathAppendW(wszPath, wszTemp);
399 else
400 StringCchCopyW(wszPath, _countof(wszPath), wszTemp);
401
402 // wszPath --> szIconFile
403 GetFullPathNameW(wszPath, cchMax, szIconFile, NULL);
404
405 return S_OK;
406 }
407
408 return E_FAIL;
409}
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:1729
int WINAPI PathParseIconLocationW(LPWSTR lpszPath)
Definition: path.c:1098
BOOL WINAPI PathIsRelativeW(LPCWSTR lpszPath)
Definition: path.c:1585
#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 412 of file CDrivesFolder.cpp.

413{
414 WCHAR wszAutoRunInfPath[MAX_PATH];
415 WCHAR wszTemp[MAX_PATH];
416
417 if (!PathIsDirectoryW(wszPath))
418 return E_FAIL;
419
420 StringCchCopyW(wszAutoRunInfPath, _countof(wszAutoRunInfPath), wszPath);
421 PathAppendW(wszAutoRunInfPath, L"autorun.inf");
422
423 if (GetPrivateProfileStringW(L"autorun", L"label", NULL, wszTemp, _countof(wszTemp),
424 wszAutoRunInfPath) && wszTemp[0] != 0)
425 {
426 StringCchCopyW(wszLabel, _countof(wszTemp), wszTemp);
427 return S_OK;
428 }
429
430 return E_FAIL;
431}

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().

◆ IsRegItem()

static const CLSID * IsRegItem ( PCUITEMID_CHILD  pidl)
static

Definition at line 71 of file CDrivesFolder.cpp.

72{
73 if (pidl && pidl->mkid.cb == 2 + 2 + sizeof(CLSID))
74 {
75 if (pidl->mkid.abID[0] == PT_SHELLEXT || pidl->mkid.abID[0] == PT_GUID) // FIXME: Remove PT_GUID when CRegFolder is fixed
76 return (const CLSID*)(&pidl->mkid.abID[2]);
77 }
78 return NULL;
79}
#define PT_GUID
Definition: pidl.h:87
#define PT_SHELLEXT
Definition: pidl.h:91

◆ SHELL32_IsShellFolderNamespaceItemHidden()

BOOL SHELL32_IsShellFolderNamespaceItemHidden ( LPCWSTR  SubKey,
REFCLSID  Clsid 
)

Definition at line 92 of file CDrivesFolder.cpp.

93{
94 // If this function returns true, the item should be hidden in DefView but not in the Explorer folder tree.
96 wsprintfW(path, L"%s\\%s", REGSTR_PATH_EXPLORER, SubKey);
98 DWORD data = 0, size = sizeof(data);
100}
#define CHARS_IN_GUID
LSTATUS WINAPI RegGetValueW(HKEY hKey, LPCWSTR pszSubKey, LPCWSTR pszValue, DWORD dwFlags, LPDWORD pdwType, PVOID pvData, LPDWORD pcbData)
Definition: reg.c:1931
#define RRF_RT_DWORD
Definition: driver.c:581
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLsizeiptr size
Definition: glext.h:5919
#define REGSTR_PATH_EXPLORER
Definition: regstr.h:33
static __inline int SHELL32_GUIDToStringW(REFGUID guid, LPWSTR str)
Definition: shfldr.h:141
Definition: name.c:39
#define HKEY_CURRENT_USER
Definition: winreg.h:11

Referenced by CDesktopFolderViewCB::ShouldShow(), and CDrivesFolder::ShouldShow().

◆ TryToLockOrUnlockDrive()

static BOOL TryToLockOrUnlockDrive ( HANDLE  hDrive,
BOOL  bLock 
)
static

Definition at line 108 of file CDrivesFolder.cpp.

109{
110 DWORD dwError, dwBytesReturned;
111 DWORD dwCode = (bLock ? FSCTL_LOCK_VOLUME : FSCTL_UNLOCK_VOLUME);
112 for (DWORD i = 0; i < RETRY_COUNT; ++i)
113 {
114 if (DeviceIoControl(hDrive, dwCode, NULL, 0, NULL, 0, &dwBytesReturned, NULL))
115 return TRUE;
116
117 dwError = GetLastError();
118 if (dwError == ERROR_INVALID_FUNCTION)
119 break; /* don't sleep if function is not implemented */
120
122 }
123 SetLastError(dwError);
124 return FALSE;
125}
#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 553 of file CDrivesFolder.cpp.

Referenced by CDrivesFolder::GetAttributesOf().

◆ dwControlPanelAttributes

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

Definition at line 556 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 | SFGAO_CANCOPY

Definition at line 558 of file CDrivesFolder.cpp.

Referenced by CDrivesFolder::GetAttributesOf().

◆ g_RegFolderInfo

const REGFOLDERINFO g_RegFolderInfo
static
Initial value:
=
{
CLSID_MyComputer,
L"::{20D04FE0-3AEA-1069-A2D8-08002B30309D}",
L"MyComputer",
}
static const REQUIREDREGITEM g_RequiredItems[]
@ PT_COMPUTER_REGITEM
Definition: ItemIDList.cpp:14

Definition at line 62 of file CDrivesFolder.cpp.

◆ g_RequiredItems

const REQUIREDREGITEM g_RequiredItems[]
static
Initial value:
=
{
{ CLSID_ControlPanel, 0, 0x50 },
}

Definition at line 58 of file CDrivesFolder.cpp.

◆ iDriveIconIds

◆ iDriveTypeIds

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

Definition at line 49 of file CDrivesFolder.cpp.

Referenced by CDrivesFolder::GetDetailsOf().

◆ MyComputerSFHeader

const shvheader MyComputerSFHeader[]
static