ReactOS 0.4.15-dev-7674-gc0b4db1
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 char 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 ::GetDriveTypeA(szDrive);
67}
#define ERR(fmt,...)
Definition: debug.h:110
DWORD _ILGetDrive(LPCITEMIDLIST pidl, LPSTR pOut, UINT uSize)
Definition: pidl.c:1870
#define _countof(array)
Definition: sndvol32.h:68
#define DRIVE_UNKNOWN
Definition: winbase.h:256

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

◆ CDrivesContextMenu_CreateInstance()

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

Definition at line 419 of file CDrivesFolder.cpp.

425{
426 HKEY hKeys[2];
427 UINT cKeys = 0;
428 AddClassKeyToArray(L"Drive", hKeys, &cKeys);
429 AddClassKeyToArray(L"Folder", hKeys, &cKeys);
430
431 return CDefFolderMenu_Create2(pidlFolder, hwnd, cidl, apidl, psf, DrivesContextMenuCallback, cKeys, hKeys, ppcm);
432}
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
void AddClassKeyToArray(const WCHAR *szClass, HKEY *array, UINT *cKeys)
Definition: shlfolder.cpp:268
_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 501 of file CDrivesFolder.cpp.

502{
503 CComPtr<IDefaultExtractIconInit> initIcon;
506 return hr;
507
508 CHAR* pszDrive = _ILGetDataPointer(pidl)->u.drive.szDriveName;
509 UINT DriveType = GetDriveTypeA(pszDrive);
512
513 WCHAR wTemp[MAX_PATH];
514 int icon_idx;
515 UINT flags = 0;
517 (HCR_GetIconW(L"Drive", wTemp, NULL, MAX_PATH, &icon_idx)))
518 {
519 initIcon->SetNormalIcon(wTemp, icon_idx);
520 }
521 else if (SUCCEEDED(getIconLocationForDrive(psf, pidl, 0, wTemp, _countof(wTemp),
522 &icon_idx, &flags)))
523 {
524 initIcon->SetNormalIcon(wTemp, icon_idx);
525 }
526 else
527 {
528 if (DriveType == DRIVE_REMOVABLE && !IsDriveFloppyA(pszDrive))
529 {
530 icon_idx = IDI_SHELL_REMOVEABLE;
531 }
532 else
533 {
534 icon_idx = iDriveIconIds[DriveType];
535 }
536 initIcon->SetNormalIcon(swShell32Name, -icon_idx);
537 }
538
539 return initIcon->QueryInterface(riid, ppvOut);
540}
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
LPPIDLDATA _ILGetDataPointer(LPCITEMIDLIST pidl)
Definition: pidl.c:2202
BOOL HCR_GetIconW(LPCWSTR szClass, LPWSTR szDest, LPCWSTR szName, DWORD len, int *picon_idx)
Definition: classes.c:288
HRESULT hr
Definition: shlfolder.c:183
#define IDI_SHELL_REMOVEABLE
Definition: shresdef.h:545
#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)
__wchar_t WCHAR
Definition: xmlstorage.h:180
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:3684

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 S_OK;
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 char szDrive[8] = {0};
289 if (!_ILGetDrive(apidl[0], szDrive, sizeof(szDrive)))
290 {
291 ERR("pidl is not a drive\n");
292 SHFree(pidlFolder);
293 _ILFreeaPidl(apidl, cidl);
294 return E_FAIL;
295 }
296 nDriveType = GetDriveTypeA(szDrive);
297 GetVolumeInformationA(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 }
347 else if (uMsg == DFM_INVOKECOMMAND)
348 {
349 WCHAR wszBuf[4] = L"A:\\";
350 wszBuf[0] = (WCHAR)szDrive[0];
351
352 INT nStringID = 0;
353 DWORD dwError = NO_ERROR;
354
356 {
357 // pdtobj should be valid at this point!
358 ATLASSERT(pdtobj);
359 hr = SH_ShowDriveProperties(wszBuf, pdtobj) ? S_OK : E_UNEXPECTED;
360 if (FAILED(hr))
361 {
362 dwError = ERROR_CAN_NOT_COMPLETE;
363 nStringID = IDS_CANTSHOWPROPERTIES;
364 }
365 }
366 else
367 {
368 if (wParam == CMDID_FORMAT)
369 {
370 hr = DoFormatDrive(hwnd, szDrive[0] - 'A');
371 }
372 else if (wParam == CMDID_EJECT)
373 {
374 /* do eject */
375 WCHAR physical[10];
376 wsprintfW(physical, _T("\\\\.\\%c:"), szDrive[0]);
377
378 if (DoEjectDrive(physical, nDriveType, &nStringID))
379 {
381 }
382 else
383 {
384 dwError = GetLastError();
385 }
386 }
387 else if (wParam == CMDID_DISCONNECT)
388 {
389 /* do disconnect */
390 wszBuf[2] = UNICODE_NULL;
391 dwError = WNetCancelConnection2W(wszBuf, 0, FALSE);
392 if (dwError == NO_ERROR)
393 {
395 }
396 else
397 {
398 nStringID = IDS_CANTDISCONNECT;
399 }
400 }
401 }
402
403 if (nStringID != 0)
404 {
405 /* show error message */
406 WCHAR szFormat[128], szMessage[128];
407 LoadStringW(shell32_hInstance, nStringID, szFormat, _countof(szFormat));
408 wsprintfW(szMessage, szFormat, dwError);
409 MessageBoxW(hwnd, szMessage, NULL, MB_ICONERROR);
410 }
411 }
412
413 SHFree(pidlFolder);
414 _ILFreeaPidl(apidl, cidl);
415
416 return hr;
417}
#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
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
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 DRIVE_CDROM
Definition: machpc98.h:119
#define UNICODE_NULL
void _ILFreeaPidl(LPITEMIDLIST *apidl, UINT cidl)
Definition: pidl.c:2661
HRESULT SH_GetApidlFromDataObject(IDataObject *pDataObject, PIDLIST_ABSOLUTE *ppidlfolder, PUITEMID_CHILD **apidlItems, UINT *pcidl)
Definition: shlfolder.cpp:328
void WINAPI _InsertMenuItemW(HMENU hmenu, UINT indexMenu, BOOL fByPosition, UINT wID, UINT fType, LPCWSTR dwTypeData, UINT fState)
#define SHCNE_DRIVEREMOVED
Definition: shlobj.h:1815
#define SHCNE_MEDIAREMOVED
Definition: shlobj.h:1814
#define SHCNF_PATHW
Definition: shlobj.h:1843
#define DFM_CMD_PROPERTIES
Definition: shlobj.h:2530
#define SHCNF_FLUSHNOWAIT
Definition: shlobj.h:1847
#define IDS_DISCONNECT
Definition: shresdef.h:244
#define IDS_EJECT
Definition: shresdef.h:243
#define IDS_CANTSHOWPROPERTIES
Definition: shresdef.h:152
#define IDS_CANTDISCONNECT
Definition: shresdef.h:153
#define IDS_FORMATDRIVE
Definition: shresdef.h:229
ITEMID_CHILD UNALIGNED * PUITEMID_CHILD
Definition: shtypes.idl:68
HMENU hmenu
Definition: shlobj.h:1381
UINT idCmdFirst
Definition: shlobj.h:1383
UINT indexMenu
Definition: shlobj.h:1382
int32_t INT
Definition: typedefs.h:58
#define _T(x)
Definition: vfdio.h:22
#define DRIVE_REMOTE
Definition: winbase.h:253
_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:786
#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:2418

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 lpString1, LPCWSTR lpString2)
Definition: lstring.c:194
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:325
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 435 of file CDrivesFolder.cpp.

437{
438 WCHAR wszPath[MAX_PATH];
439 WCHAR wszAutoRunInfPath[MAX_PATH];
440 WCHAR wszValue[MAX_PATH], wszTemp[MAX_PATH];
441
442 // get path
443 if (!ILGetDisplayNameExW(psf, pidl, wszPath, 0))
444 return E_FAIL;
445 if (!PathIsDirectoryW(wszPath))
446 return E_FAIL;
447
448 // build the full path of autorun.inf
449 StringCchCopyW(wszAutoRunInfPath, _countof(wszAutoRunInfPath), wszPath);
450 PathAppendW(wszAutoRunInfPath, L"autorun.inf");
451
452 // autorun.inf --> wszValue
453 if (GetPrivateProfileStringW(L"autorun", L"icon", NULL, wszValue, _countof(wszValue),
454 wszAutoRunInfPath) && wszValue[0] != 0)
455 {
456 // wszValue --> wszTemp
457 ExpandEnvironmentStringsW(wszValue, wszTemp, _countof(wszTemp));
458
459 // parse the icon location
460 *piIndex = PathParseIconLocationW(wszTemp);
461
462 // wszPath + wszTemp --> wszPath
463 if (PathIsRelativeW(wszTemp))
464 PathAppendW(wszPath, wszTemp);
465 else
466 StringCchCopyW(wszPath, _countof(wszPath), wszTemp);
467
468 // wszPath --> szIconFile
469 GetFullPathNameW(wszPath, cchMax, szIconFile, NULL);
470
471 return S_OK;
472 }
473
474 return E_FAIL;
475}
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:91
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 478 of file CDrivesFolder.cpp.

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

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

Referenced by CDrivesFolder::GetAttributesOf().

◆ dwControlPanelAttributes

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

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

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

◆ iDriveIconIds

int iDriveIconIds[7]
static
Initial value:
}
#define IDI_SHELL_3_14_FLOPPY
Definition: shresdef.h:544
#define IDI_SHELL_NETDRIVE
Definition: shresdef.h:547
#define IDI_SHELL_CDROM
Definition: shresdef.h:549
#define IDI_SHELL_DRIVE
Definition: shresdef.h:546
#define IDI_SHELL_RAMDISK
Definition: shresdef.h:550

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: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