ReactOS 0.4.15-dev-5865-g640e228
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)
 
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

◆ MYCOMPUTERSHELLVIEWCOLUMNS

#define MYCOMPUTERSHELLVIEWCOLUMNS   5

Definition at line 575 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

◆ CDrivesContextMenu_CreateInstance()

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

Definition at line 408 of file CDrivesFolder.cpp.

414{
415 HKEY hKeys[2];
416 UINT cKeys = 0;
417 AddClassKeyToArray(L"Drive", hKeys, &cKeys);
418 AddClassKeyToArray(L"Folder", hKeys, &cKeys);
419
420 return CDefFolderMenu_Create2(pidlFolder, hwnd, cidl, apidl, psf, DrivesContextMenuCallback, cKeys, hKeys, ppcm);
421}
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 490 of file CDrivesFolder.cpp.

491{
492 CComPtr<IDefaultExtractIconInit> initIcon;
495 return hr;
496
497 CHAR* pszDrive = _ILGetDataPointer(pidl)->u.drive.szDriveName;
498 UINT DriveType = GetDriveTypeA(pszDrive);
501
502 WCHAR wTemp[MAX_PATH];
503 int icon_idx;
504 UINT flags = 0;
506 (HCR_GetIconW(L"Drive", wTemp, NULL, MAX_PATH, &icon_idx)))
507 {
508 initIcon->SetNormalIcon(wTemp, icon_idx);
509 }
510 else if (SUCCEEDED(getIconLocationForDrive(psf, pidl, 0, wTemp, _countof(wTemp),
511 &icon_idx, &flags)))
512 {
513 initIcon->SetNormalIcon(wTemp, icon_idx);
514 }
515 else
516 {
517 if (DriveType == DRIVE_REMOVABLE && !IsDriveFloppyA(pszDrive))
518 {
519 icon_idx = IDI_SHELL_REMOVEABLE;
520 }
521 else
522 {
523 icon_idx = iDriveIconIds[DriveType];
524 }
525 initIcon->SetNormalIcon(swShell32Name, -icon_idx);
526 }
527
528 return initIcon->QueryInterface(riid, ppvOut);
529}
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:372
HRESULT WINAPI SHCreateDefaultExtractIcon(REFIID riid, void **ppv)
UINT DriveType
#define NULL
Definition: types.h:112
#define MAX_PATH
Definition: compat.h:34
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:2187
BOOL HCR_GetIconW(LPCWSTR szClass, LPWSTR szDest, LPCWSTR szName, DWORD len, int *picon_idx)
Definition: classes.c:288
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:82
HRESULT hr
Definition: shlfolder.c:183
#define IDI_SHELL_REMOVEABLE
Definition: shresdef.h:539
#define _countof(array)
Definition: sndvol32.h:68
#define DRIVE_UNKNOWN
Definition: winbase.h:256
#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 84 of file CDrivesFolder.cpp.

85{
86 /* GENERIC_WRITE isn't needed for umount */
87 DWORD dwAccessMode = GENERIC_READ;
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;
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 {
137 }
138
139 CloseHandle(hDrive);
140
141 SetLastError(dwError);
142 return bResult;
143}
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:149
#define IDS_CANTLOCKVOLUME
Definition: shresdef.h:148
#define IDS_CANTEJECTMEDIA
Definition: shresdef.h:150
BOOLEAN PreventMediaRemoval
Definition: ntddstor.h:343
DWORD WINAPI GetLastError(void)
Definition: except.c:1040
#define CreateFile
Definition: winbase.h:3620

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}
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 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;
273 HRESULT hr = SH_GetApidlFromDataObject(pdtobj, &pidlFolder, &apidl, &cidl);
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#if 0 // Disabled until our menu building system is fixed
290#define CMDID_FORMAT 0
291#define CMDID_EJECT 1
292#define CMDID_DISCONNECT 2
293#else
294/* FIXME: These IDs should start from 0, however there is difference
295 * between ours and Windows' menu building systems, which should be fixed. */
296#define CMDID_FORMAT 1
297#define CMDID_EJECT 2
298#define CMDID_DISCONNECT 3
299#endif
300
301 if (uMsg == DFM_MERGECONTEXTMENU)
302 {
303 QCMINFO *pqcminfo = (QCMINFO *)lParam;
304
305 UINT idCmdFirst = pqcminfo->idCmdFirst;
306 UINT idCmd = 0;
307 if (!(dwFlags & FILE_READ_ONLY_VOLUME) && nDriveType != DRIVE_REMOTE)
308 {
309 /* add separator and Format */
310 idCmd = idCmdFirst + CMDID_FORMAT;
311 _InsertMenuItemW(pqcminfo->hmenu, pqcminfo->indexMenu++, TRUE, 0, MFT_SEPARATOR, NULL, 0);
313 }
314 if (nDriveType == DRIVE_REMOVABLE || nDriveType == DRIVE_CDROM)
315 {
316 /* add separator and Eject */
317 idCmd = idCmdFirst + CMDID_EJECT;
318 _InsertMenuItemW(pqcminfo->hmenu, pqcminfo->indexMenu++, TRUE, 0, MFT_SEPARATOR, NULL, 0);
320 }
321 if (nDriveType == DRIVE_REMOTE)
322 {
323 /* add separator and Disconnect */
324 idCmd = idCmdFirst + CMDID_DISCONNECT;
325 _InsertMenuItemW(pqcminfo->hmenu, pqcminfo->indexMenu++, TRUE, 0, MFT_SEPARATOR, NULL, 0);
327 }
328
329 if (idCmd)
330#if 0 // see FIXME above
331 pqcminfo->idCmdFirst = ++idCmd;
332#else
333 pqcminfo->idCmdFirst = (idCmd + 2);
334#endif
335 }
336 else if (uMsg == DFM_INVOKECOMMAND)
337 {
338 WCHAR wszBuf[4] = L"A:\\";
339 wszBuf[0] = (WCHAR)szDrive[0];
340
341 INT nStringID = 0;
342 DWORD dwError = NO_ERROR;
343
345 {
346 // pdtobj should be valid at this point!
347 ATLASSERT(pdtobj);
348 hr = SH_ShowDriveProperties(wszBuf, pdtobj) ? S_OK : E_UNEXPECTED;
349 if (FAILED(hr))
350 {
351 dwError = ERROR_CAN_NOT_COMPLETE;
352 nStringID = IDS_CANTSHOWPROPERTIES;
353 }
354 }
355 else
356 {
357 if (wParam == CMDID_FORMAT)
358 {
359 hr = DoFormatDrive(hwnd, szDrive[0] - 'A');
360 }
361 else if (wParam == CMDID_EJECT)
362 {
363 /* do eject */
364 WCHAR physical[10];
365 wsprintfW(physical, _T("\\\\.\\%c:"), szDrive[0]);
366
367 if (DoEjectDrive(physical, nDriveType, &nStringID))
368 {
370 }
371 else
372 {
373 dwError = GetLastError();
374 }
375 }
376 else if (wParam == CMDID_DISCONNECT)
377 {
378 /* do disconnect */
379 wszBuf[2] = UNICODE_NULL;
380 dwError = WNetCancelConnection2W(wszBuf, 0, FALSE);
381 if (dwError == NO_ERROR)
382 {
384 }
385 else
386 {
387 nStringID = IDS_CANTDISCONNECT;
388 }
389 }
390 }
391
392 if (nStringID != 0)
393 {
394 /* show error message */
395 WCHAR szFormat[128], szMessage[128];
396 LoadStringW(shell32_hInstance, nStringID, szFormat, _countof(szFormat));
397 wsprintfW(szMessage, szFormat, dwError);
398 MessageBoxW(hwnd, szMessage, NULL, MB_ICONERROR);
399 }
400 }
401
402 SHFree(pidlFolder);
403 _ILFreeaPidl(apidl, cidl);
404
405 return hr;
406}
#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
#define ERR(fmt,...)
Definition: debug.h:110
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:115
#define UNICODE_NULL
DWORD _ILGetDrive(LPCITEMIDLIST pidl, LPSTR pOut, UINT uSize)
Definition: pidl.c:1855
void _ILFreeaPidl(LPITEMIDLIST *apidl, UINT cidl)
Definition: pidl.c:2646
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:1749
#define SHCNE_MEDIAREMOVED
Definition: shlobj.h:1748
#define SHCNF_PATHW
Definition: shlobj.h:1777
#define DFM_CMD_PROPERTIES
Definition: shlobj.h:2464
#define SHCNF_FLUSHNOWAIT
Definition: shlobj.h:1781
#define IDS_DISCONNECT
Definition: shresdef.h:243
#define IDS_EJECT
Definition: shresdef.h:242
#define IDS_CANTSHOWPROPERTIES
Definition: shresdef.h:151
#define IDS_CANTDISCONNECT
Definition: shresdef.h:152
#define IDS_FORMATDRIVE
Definition: shresdef.h:228
ITEMID_CHILD UNALIGNED * PUITEMID_CHILD
Definition: shtypes.idl:68
HMENU hmenu
Definition: shlobj.h:1315
UINT idCmdFirst
Definition: shlobj.h:1317
UINT indexMenu
Definition: shlobj.h:1316
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:739
int WINAPI MessageBoxW(_In_opt_ HWND hWnd, _In_opt_ LPCWSTR lpText, _In_opt_ LPCWSTR lpCaption, _In_ UINT uType)
#define MB_ICONERROR
Definition: winuser.h:781
#define MFS_ENABLED
Definition: winuser.h:745
#define MFT_STRING
Definition: winuser.h:741
#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 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}
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 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}
#define GW_OWNER
Definition: winuser.h:761
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 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}
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:297
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 424 of file CDrivesFolder.cpp.

426{
427 WCHAR wszPath[MAX_PATH];
428 WCHAR wszAutoRunInfPath[MAX_PATH];
429 WCHAR wszValue[MAX_PATH], wszTemp[MAX_PATH];
430
431 // get path
432 if (!ILGetDisplayNameExW(psf, pidl, wszPath, 0))
433 return E_FAIL;
434 if (!PathIsDirectoryW(wszPath))
435 return E_FAIL;
436
437 // build the full path of autorun.inf
438 StringCchCopyW(wszAutoRunInfPath, _countof(wszAutoRunInfPath), wszPath);
439 PathAppendW(wszAutoRunInfPath, L"autorun.inf");
440
441 // autorun.inf --> wszValue
442 if (GetPrivateProfileStringW(L"autorun", L"icon", NULL, wszValue, _countof(wszValue),
443 wszAutoRunInfPath) && wszValue[0] != 0)
444 {
445 // wszValue --> wszTemp
446 ExpandEnvironmentStringsW(wszValue, wszTemp, _countof(wszTemp));
447
448 // parse the icon location
449 *piIndex = PathParseIconLocationW(wszTemp);
450
451 // wszPath + wszTemp --> wszPath
452 if (PathIsRelativeW(wszTemp))
453 PathAppendW(wszPath, wszTemp);
454 else
455 StringCchCopyW(wszPath, _countof(wszPath), wszTemp);
456
457 // wszPath --> szIconFile
458 GetFullPathNameW(wszPath, cchMax, szIconFile, NULL);
459
460 return S_OK;
461 }
462
463 return E_FAIL;
464}
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 PathAppendW(LPWSTR lpszPath, LPCWSTR lpszAppend)
Definition: path.c:126
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
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 467 of file CDrivesFolder.cpp.

468{
469 WCHAR wszAutoRunInfPath[MAX_PATH];
470 WCHAR wszTemp[MAX_PATH];
471
472 if (!PathIsDirectoryW(wszPath))
473 return E_FAIL;
474
475 StringCchCopyW(wszAutoRunInfPath, _countof(wszAutoRunInfPath), wszPath);
476 PathAppendW(wszAutoRunInfPath, L"autorun.inf");
477
478 if (GetPrivateProfileStringW(L"autorun", L"label", NULL, wszTemp, _countof(wszTemp),
479 wszAutoRunInfPath) && wszTemp[0] != 0)
480 {
481 StringCchCopyW(wszLabel, _countof(wszTemp), wszTemp);
482 return S_OK;
483 }
484
485 return E_FAIL;
486}

Referenced by CDrivesFolder::GetDisplayNameOf().

◆ IsDriveFloppyA()

BOOL IsDriveFloppyA ( LPCSTR  pszDriveRoot)

Definition at line 372 of file drvdefext.cpp.

373{
374 WCHAR szRoot[8];
375 MultiByteToWideChar(CP_ACP, 0, pszDriveRoot, -1, szRoot, _countof(szRoot));
376 return IsDriveFloppyW(szRoot);
377}
#define CP_ACP
Definition: compat.h:109
#define MultiByteToWideChar
Definition: compat.h:110
BOOL IsDriveFloppyW(LPCWSTR pszDriveRoot)
Definition: drvdefext.cpp:306

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

Referenced by CDrivesFolder::GetAttributesOf().

◆ dwControlPanelAttributes

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

Definition at line 580 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 582 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:538
#define IDI_SHELL_NETDRIVE
Definition: shresdef.h:541
#define IDI_SHELL_CDROM
Definition: shresdef.h:543
#define IDI_SHELL_DRIVE
Definition: shresdef.h:540
#define IDI_SHELL_RAMDISK
Definition: shresdef.h:544

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

Definition at line 567 of file CDrivesFolder.cpp.

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