c862c79855ba9ea78298ede7c7a6bdedc247b56a
[reactos.git] / reactos / dll / win32 / shell32 / folder_options.c
1 /*
2 * Open With Context Menu extension
3 *
4 * Copyright 2007 Johannes Anderwald <janderwald@reactos.org>
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20
21 #include <precomp.h>
22
23
24 WINE_DEFAULT_DEBUG_CHANNEL (fprop);
25 #define MAX_PROPERTY_SHEET_PAGE (32)
26
27 /// Folder Options:
28 /// CLASSKEY = HKEY_CLASSES_ROOT\CLSID\{6DFD7C5C-2451-11d3-A299-00C04F8EF6AF}
29 /// DefaultIcon = %SystemRoot%\system32\SHELL32.dll,-210
30 /// Verbs: Open / RunAs
31 /// Cmd: rundll32.exe shell32.dll,Options_RunDLL 0
32
33 /// ShellFolder Attributes: 0x0
34
35 typedef struct
36 {
37 DWORD cFiles;
38 DWORD cFolder;
39 LARGE_INTEGER bSize;
40 HWND hwndDlg;
41 WCHAR szFolderPath[MAX_PATH];
42 }FOLDER_PROPERTIES_CONTEXT, *PFOLDER_PROPERTIES_CONTEXT;
43
44 typedef struct
45 {
46 LPCWSTR szKeyName;
47 UINT ResourceID;
48 }FOLDER_VIEW_ENTRY, PFOLDER_VIEW_ENTRY;
49 /*
50 static FOLDER_VIEW_ENTRY s_Options[] =
51 {
52 { L"AlwaysShowMenus", IDS_ALWAYSSHOWMENUS },
53 { L"AutoCheckSelect", -1 },
54 { L"ClassicViewState", -1 },
55 { L"DontPrettyPath", -1 },
56 { L"Filter", -1 },
57 { L"FolderContentsInfoTip", IDS_FOLDERCONTENTSTIP },
58 { L"FriendlyTree", -1 },
59 { L"Hidden", -1, },
60 { L"HideFileExt", IDS_HIDEFILEEXT },
61 { L"HideIcons", -1},
62 { L"IconsOnly", -1},
63 { L"ListviewAlphaSelect", -1},
64 { L"ListviewShadow", -1},
65 { L"ListviewWatermark", -1},
66 { L"MapNetDrvBtn", -1},
67 { L"PersistBrowsers", -1},
68 { L"SeperateProcess", IDS_SEPERATEPROCESS},
69 { L"ServerAdminUI", -1},
70 { L"SharingWizardOn", IDS_USESHAREWIZARD},
71 { L"ShowCompColor", IDS_COMPCOLOR},
72 { L"ShowInfoTip", IDS_SHOWINFOTIP},
73 { L"ShowPreviewHandlers", -1},
74 { L"ShowSuperHidden", IDS_HIDEOSFILES},
75 { L"ShowTypeOverlay", -1},
76 { L"Start_ShowMyGames", -1},
77 { L"StartMenuInit", -1},
78 { L"SuperHidden", -1},
79 { L"TypeAhead", -1},
80 { L"Webview", -1},
81 { NULL, -1}
82
83 };
84 */
85
86 HPSXA WINAPI SHCreatePropSheetExtArrayEx(HKEY hKey, LPCWSTR pszSubKey, UINT max_iface, IDataObject *pDataObj);
87
88 INT_PTR
89 CALLBACK
90 FolderOptionsGeneralDlg(
91 HWND hwndDlg,
92 UINT uMsg,
93 WPARAM wParam,
94 LPARAM lParam
95 )
96 {
97
98
99
100 return FALSE;
101 }
102
103 static
104 VOID
105 InitializeFolderOptionsListCtrl(HWND hwndDlg)
106 {
107 RECT clientRect;
108 LVCOLUMNW col;
109 WCHAR szName[50];
110 HWND hDlgCtrl;
111
112 hDlgCtrl = GetDlgItem(hwndDlg, 14003);
113
114 if (!LoadStringW(shell32_hInstance, IDS_COLUMN_EXTENSION, szName, sizeof(szName) / sizeof(WCHAR)))
115 szName[0] = 0;
116 szName[(sizeof(szName)/sizeof(WCHAR))-1] = 0;
117
118 GetClientRect(hDlgCtrl, &clientRect);
119 ZeroMemory(&col, sizeof(LV_COLUMN));
120 col.mask = LVCF_SUBITEM | LVCF_WIDTH | LVCF_FMT;
121 col.iSubItem = 0;
122 col.pszText = szName;
123 col.fmt = LVCFMT_LEFT;
124 col.cx = (clientRect.right - clientRect.left) - GetSystemMetrics(SM_CXVSCROLL);
125 (void)SendMessageW(hDlgCtrl, LVM_INSERTCOLUMN, 0, (LPARAM)&col);
126
127
128
129 }
130
131
132 INT_PTR
133 CALLBACK
134 FolderOptionsViewDlg(
135 HWND hwndDlg,
136 UINT uMsg,
137 WPARAM wParam,
138 LPARAM lParam
139 )
140 {
141 switch(uMsg)
142 {
143 case WM_INITDIALOG:
144 InitializeFolderOptionsListCtrl(hwndDlg);
145 return TRUE;
146 }
147
148 return FALSE;
149
150 }
151
152 VOID
153 InitializeFileTypesListCtrlColumns(HWND hDlgCtrl)
154 {
155 RECT clientRect;
156 LVCOLUMNW col;
157 WCHAR szName[50];
158
159 if (!LoadStringW(shell32_hInstance, IDS_COLUMN_EXTENSION, szName, sizeof(szName) / sizeof(WCHAR)))
160 szName[0] = 0;
161 szName[(sizeof(szName)/sizeof(WCHAR))-1] = 0;
162
163 GetClientRect(hDlgCtrl, &clientRect);
164 ZeroMemory(&col, sizeof(LV_COLUMN));
165 col.mask = LVCF_SUBITEM | LVCF_WIDTH | LVCF_FMT;
166 col.iSubItem = 0;
167 col.pszText = szName;
168 col.fmt = LVCFMT_LEFT;
169 col.cx = (clientRect.right - clientRect.left) - GetSystemMetrics(SM_CXVSCROLL);
170 (void)SendMessageW(hDlgCtrl, LVM_INSERTCOLUMNW, 0, (LPARAM)&col);
171 }
172 INT
173 FindItem(HWND hDlgCtrl, WCHAR * ItemName)
174 {
175 LVFINDINFOW findInfo;
176 ZeroMemory(&findInfo, sizeof(LVFINDINFOW));
177
178 findInfo.flags = LVFI_STRING;
179 findInfo.psz = ItemName;
180 return ListView_FindItem(hDlgCtrl, 0, &findInfo);
181 }
182
183 VOID
184 InsertFileType(HWND hDlgCtrl, WCHAR * szName, DWORD Size, INT iItem)
185 {
186 WCHAR szPath[100];
187 HKEY hKey;
188 LVITEMW lvItem;
189 DWORD dwSize;
190
191 if (FindItem(hDlgCtrl, szName) != -1)
192 return;
193
194 wcscpy(szPath, szName);
195 /* get the name */
196 if (RegOpenKeyExW(HKEY_CLASSES_ROOT, szPath, 0, KEY_READ, &hKey) == ERROR_SUCCESS)
197 {
198 if (RegLoadMUIStringW(hKey, L"FriendlyTypeName", szName, Size, NULL, 0, NULL) != ERROR_SUCCESS)
199 {
200 dwSize = Size;
201 if (RegQueryValueExW(hKey, NULL, NULL, NULL, (LPBYTE)szName, &dwSize) != ERROR_SUCCESS)
202 {
203 wcscpy(szName, szPath);
204 }
205 }
206 RegCloseKey(hKey);
207 szName[(Size/sizeof(WCHAR))-1] = 0;
208 }
209 wcscat(szPath, L"\\shell");
210
211 ZeroMemory(&lvItem, sizeof(LVITEMW));
212 lvItem.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE;
213 lvItem.state = LVIS_SELECTED;
214 lvItem.pszText = szName;
215 lvItem.iItem = iItem;
216
217 if (RegOpenKeyExW(HKEY_CLASSES_ROOT, szPath, 0, KEY_READ, &hKey) == ERROR_SUCCESS)
218 {
219 lvItem.lParam = 0;
220 (void)SendMessageW(hDlgCtrl, LVM_INSERTITEMW, 0, (LPARAM)&lvItem);
221 RegCloseKey(hKey);
222 }
223 }
224
225 BOOL
226 InitializeFileTypesListCtrl(HWND hwndDlg)
227 {
228 HWND hDlgCtrl;
229 DWORD dwIndex = 0;
230 WCHAR szName[50];
231 DWORD dwName;
232 INT iItem = 0;
233
234 hDlgCtrl = GetDlgItem(hwndDlg, 14000);
235 InitializeFileTypesListCtrlColumns(hDlgCtrl);
236
237 dwName = sizeof(szName) / sizeof(WCHAR);
238
239 while(RegEnumKeyExW(HKEY_CLASSES_ROOT, dwIndex++, szName, &dwName, NULL, NULL, NULL, NULL) == ERROR_SUCCESS)
240 {
241 InsertFileType(hDlgCtrl, szName, sizeof(szName), iItem++);
242 dwName = sizeof(szName) / sizeof(WCHAR);
243 }
244 return TRUE;
245 }
246
247
248 INT_PTR
249 CALLBACK
250 FolderOptionsFileTypesDlg(
251 HWND hwndDlg,
252 UINT uMsg,
253 WPARAM wParam,
254 LPARAM lParam
255 )
256 {
257 switch(uMsg)
258 {
259 case WM_INITDIALOG:
260 InitializeFileTypesListCtrl(hwndDlg);
261 return TRUE;
262 }
263
264 return FALSE;
265 }
266
267
268 VOID
269 ShowFolderOptionsDialog(HWND hWnd, HINSTANCE hInst)
270 {
271 PROPSHEETHEADERW pinfo;
272 HPROPSHEETPAGE hppages[3];
273 HPROPSHEETPAGE hpage;
274 UINT num_pages = 0;
275 WCHAR szOptions[100];
276
277 hpage = SH_CreatePropertySheetPage("FOLDER_OPTIONS_GENERAL_DLG", FolderOptionsGeneralDlg, 0, NULL);
278 if (hpage)
279 hppages[num_pages++] = hpage;
280
281 hpage = SH_CreatePropertySheetPage("FOLDER_OPTIONS_VIEW_DLG", FolderOptionsViewDlg, 0, NULL);
282 if (hpage)
283 hppages[num_pages++] = hpage;
284
285 hpage = SH_CreatePropertySheetPage("FOLDER_OPTIONS_FILETYPES_DLG", FolderOptionsFileTypesDlg, 0, NULL);
286 if (hpage)
287 hppages[num_pages++] = hpage;
288
289 szOptions[0] = L'\0';
290 LoadStringW(shell32_hInstance, IDS_FOLDER_OPTIONS, szOptions, sizeof(szOptions) / sizeof(WCHAR));
291 szOptions[(sizeof(szOptions)/sizeof(WCHAR))-1] = L'\0';
292
293 memset(&pinfo, 0x0, sizeof(PROPSHEETHEADERW));
294 pinfo.dwSize = sizeof(PROPSHEETHEADERW);
295 pinfo.dwFlags = PSH_NOCONTEXTHELP;
296 pinfo.nPages = num_pages;
297 pinfo.u3.phpage = hppages;
298 pinfo.pszCaption = szOptions;
299
300 PropertySheetW(&pinfo);
301 }
302
303 VOID
304 Options_RunDLLCommon(HWND hWnd, HINSTANCE hInst, int fOptions, DWORD nCmdShow)
305 {
306 switch(fOptions)
307 {
308 case 0:
309 ShowFolderOptionsDialog(hWnd, hInst);
310 break;
311 case 1:
312 // show taskbar options dialog
313 FIXME("notify explorer to show taskbar options dialog");
314 //PostMessage(GetShellWindow(), WM_USER+22, fOptions, 0);
315 break;
316 default:
317 FIXME("unrecognized options id %d\n", fOptions);
318 }
319 }
320
321 /*************************************************************************
322 * Options_RunDLL (SHELL32.@)
323 */
324 VOID WINAPI Options_RunDLL(HWND hWnd, HINSTANCE hInst, LPCSTR cmd, DWORD nCmdShow)
325 {
326 Options_RunDLLCommon(hWnd, hInst, StrToIntA(cmd), nCmdShow);
327 }
328 /*************************************************************************
329 * Options_RunDLLA (SHELL32.@)
330 */
331 VOID WINAPI Options_RunDLLA(HWND hWnd, HINSTANCE hInst, LPCSTR cmd, DWORD nCmdShow)
332 {
333 Options_RunDLLCommon(hWnd, hInst, StrToIntA(cmd), nCmdShow);
334 }
335
336 /*************************************************************************
337 * Options_RunDLLW (SHELL32.@)
338 */
339 VOID WINAPI Options_RunDLLW(HWND hWnd, HINSTANCE hInst, LPCWSTR cmd, DWORD nCmdShow)
340 {
341 Options_RunDLLCommon(hWnd, hInst, StrToIntW(cmd), nCmdShow);
342 }
343
344 static
345 DWORD WINAPI
346 CountFolderAndFiles(LPVOID lParam)
347 {
348 WIN32_FIND_DATAW FindData;
349 HANDLE hFile;
350 UINT Length;
351 LPWSTR pOffset;
352 BOOL ret;
353 PFOLDER_PROPERTIES_CONTEXT pContext = (PFOLDER_PROPERTIES_CONTEXT) lParam;
354
355 pOffset = PathAddBackslashW(pContext->szFolderPath);
356 if (!pOffset)
357 return 0;
358
359 Length = pOffset - pContext->szFolderPath;
360
361 wcscpy(pOffset, L"*.*");
362 hFile = FindFirstFileW(pContext->szFolderPath, &FindData);
363 if (hFile == INVALID_HANDLE_VALUE)
364 return 0;
365
366 do
367 {
368 ret = FindNextFileW(hFile, &FindData);
369 if (ret)
370 {
371 if (FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
372 {
373 if (FindData.cFileName[0] == L'.' && FindData.cFileName[1] == L'.' &&
374 FindData.cFileName[2] == L'\0')
375 continue;
376
377 pContext->cFolder++;
378 wcscpy(pOffset, FindData.cFileName);
379 CountFolderAndFiles((LPVOID)pContext);
380 pOffset[0] = L'\0';
381 }
382 else
383 {
384 pContext->cFiles++;
385 pContext->bSize.u.LowPart += FindData.nFileSizeLow;
386 pContext->bSize.u.HighPart += FindData.nFileSizeHigh;
387 }
388 }
389 else if (GetLastError() == ERROR_NO_MORE_FILES)
390 {
391 break;
392 }
393 }while(1);
394
395 FindClose(hFile);
396 return 1;
397 }
398
399 static
400 VOID
401 InitializeFolderGeneralDlg(PFOLDER_PROPERTIES_CONTEXT pContext)
402 {
403 LPWSTR pFolderName;
404 WIN32_FILE_ATTRIBUTE_DATA FolderAttribute;
405 FILETIME ft;
406 SYSTEMTIME dt;
407 WCHAR szBuffer[MAX_PATH+5];
408 WCHAR szFormat[30] = {0};
409
410 static const WCHAR wFormat[] = {'%','0','2','d','/','%','0','2','d','/','%','0','4','d',' ',' ','%','0','2','d',':','%','0','2','u',0};
411
412 pFolderName = wcsrchr(pContext->szFolderPath, L'\\');
413 if (!pFolderName)
414 return;
415
416 /* set folder name */
417 SendDlgItemMessageW(pContext->hwndDlg, 14001, WM_SETTEXT, 0, (LPARAM) (pFolderName + 1));
418 /* set folder location */
419 pFolderName[0] = L'\0';
420 if (wcslen(pContext->szFolderPath) == 2)
421 {
422 /* folder is located at root */
423 WCHAR szDrive[4] = {L'C',L':',L'\\',L'\0'};
424 szDrive[0] = pContext->szFolderPath[0];
425 SendDlgItemMessageW(pContext->hwndDlg, 14007, WM_SETTEXT, 0, (LPARAM) szDrive);
426 }
427 else
428 {
429 SendDlgItemMessageW(pContext->hwndDlg, 14007, WM_SETTEXT, 0, (LPARAM) pContext->szFolderPath);
430 }
431 pFolderName[0] = L'\\';
432 /* get folder properties */
433 if (GetFileAttributesExW(pContext->szFolderPath, GetFileExInfoStandard, (LPVOID)&FolderAttribute))
434 {
435 if (FolderAttribute.dwFileAttributes & FILE_ATTRIBUTE_READONLY)
436 {
437 /* check readonly button */
438 SendDlgItemMessage(pContext->hwndDlg, 14021, BM_SETCHECK, BST_CHECKED, 0);
439 }
440
441 if (FolderAttribute.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN)
442 {
443 /* check hidden button */
444 SendDlgItemMessage(pContext->hwndDlg, 14022, BM_SETCHECK, BST_CHECKED, 0);
445 }
446
447 if (FileTimeToLocalFileTime(&FolderAttribute.ftCreationTime, &ft))
448 {
449 FileTimeToSystemTime(&ft, &dt);
450 swprintf (szBuffer, wFormat, dt.wDay, dt.wMonth, dt.wYear, dt.wHour, dt.wMinute);
451 SendDlgItemMessageW(pContext->hwndDlg, 14015, WM_SETTEXT, 0, (LPARAM) szBuffer);
452 }
453 }
454 /* now enumerate enumerate contents */
455 wcscpy(szBuffer, pContext->szFolderPath);
456 CountFolderAndFiles((LPVOID)pContext);
457 wcscpy(pContext->szFolderPath, szBuffer);
458 /* set folder details */
459 LoadStringW(shell32_hInstance, IDS_FILE_FOLDER, szFormat, sizeof(szFormat)/sizeof(WCHAR));
460 szFormat[(sizeof(szFormat)/sizeof(WCHAR))-1] = L'\0';
461 swprintf(szBuffer, szFormat, pContext->cFiles, pContext->cFolder);
462 SendDlgItemMessageW(pContext->hwndDlg, 14011, WM_SETTEXT, 0, (LPARAM) szBuffer);
463
464 if (StrFormatByteSizeW(pContext->bSize.QuadPart, szBuffer, sizeof(szBuffer)/sizeof(WCHAR)))
465 {
466 /* store folder size */
467 SendDlgItemMessageW(pContext->hwndDlg, 14009, WM_SETTEXT, 0, (LPARAM) szBuffer);
468 }
469 }
470
471
472 INT_PTR
473 CALLBACK
474 FolderPropertiesGeneralDlg(
475 HWND hwndDlg,
476 UINT uMsg,
477 WPARAM wParam,
478 LPARAM lParam
479 )
480 {
481 LPPROPSHEETPAGEW ppsp;
482 PFOLDER_PROPERTIES_CONTEXT pContext;
483 HICON hIcon;
484 WIN32_FILE_ATTRIBUTE_DATA FolderAttribute;
485 LONG res;
486 LPPSHNOTIFY lppsn;
487 DWORD Attribute;
488
489 switch(uMsg)
490 {
491 case WM_INITDIALOG:
492 ppsp = (LPPROPSHEETPAGEW)lParam;
493 if (ppsp == NULL)
494 break;
495 hIcon = LoadIconW(shell32_hInstance, MAKEINTRESOURCEW(IDI_SHELL_FOLDER_OPEN));
496 if (hIcon)
497 SendDlgItemMessageW(hwndDlg, 14000, STM_SETICON, (WPARAM)hIcon, 0);
498
499 pContext = SHAlloc(sizeof(FOLDER_PROPERTIES_CONTEXT));
500 if (pContext)
501 {
502 ZeroMemory(pContext, sizeof(FOLDER_PROPERTIES_CONTEXT));
503 pContext->hwndDlg = hwndDlg;
504 wcscpy(pContext->szFolderPath, (LPWSTR)ppsp->lParam);
505 SetWindowLongPtr(hwndDlg, DWL_USER, (LONG_PTR)pContext);
506 InitializeFolderGeneralDlg(pContext);
507 }
508 return TRUE;
509 case WM_COMMAND:
510 if (HIWORD(wParam) == BN_CLICKED)
511 {
512 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
513 }
514 break;
515 case WM_DESTROY:
516 pContext = (PFOLDER_PROPERTIES_CONTEXT)GetWindowLongPtr(hwndDlg, DWL_USER);
517 SHFree((LPVOID)pContext);
518 break;
519 case WM_NOTIFY:
520 pContext = (PFOLDER_PROPERTIES_CONTEXT)GetWindowLongPtr(hwndDlg, DWL_USER);
521 lppsn = (LPPSHNOTIFY) lParam;
522 if (lppsn->hdr.code == PSN_APPLY)
523 {
524 if (GetFileAttributesExW(pContext->szFolderPath, GetFileExInfoStandard, (LPVOID)&FolderAttribute))
525 {
526 res = SendDlgItemMessageW(hwndDlg, 14021, BM_GETCHECK, 0, 0);
527 if (res == BST_CHECKED)
528 FolderAttribute.dwFileAttributes |= FILE_ATTRIBUTE_READONLY;
529 else
530 FolderAttribute.dwFileAttributes &= (~FILE_ATTRIBUTE_READONLY);
531
532 res = SendDlgItemMessageW(hwndDlg, 14022, BM_GETCHECK, 0, 0);
533 if (res == BST_CHECKED)
534 FolderAttribute.dwFileAttributes |= FILE_ATTRIBUTE_HIDDEN;
535 else
536 FolderAttribute.dwFileAttributes &= (~FILE_ATTRIBUTE_HIDDEN);
537
538 Attribute = FolderAttribute.dwFileAttributes &
539 (FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_NORMAL|FILE_ATTRIBUTE_READONLY|FILE_ATTRIBUTE_SYSTEM|FILE_ATTRIBUTE_TEMPORARY);
540
541 SetFileAttributesW(pContext->szFolderPath, Attribute);
542 }
543 SetWindowLongPtr( hwndDlg, DWL_MSGRESULT, PSNRET_NOERROR );
544 return TRUE;
545 }
546 break;
547 }
548 return FALSE;
549 }
550
551 static
552 BOOL
553 CALLBACK
554 FolderAddPropSheetPageProc(HPROPSHEETPAGE hpage, LPARAM lParam)
555 {
556 PROPSHEETHEADERW *ppsh = (PROPSHEETHEADERW *)lParam;
557 if (ppsh != NULL && ppsh->nPages < MAX_PROPERTY_SHEET_PAGE)
558 {
559 ppsh->u3.phpage[ppsh->nPages++] = hpage;
560 return TRUE;
561 }
562 return FALSE;
563 }
564
565 BOOL
566 SH_ShowFolderProperties(LPWSTR pwszFolder, LPCITEMIDLIST pidlFolder, LPCITEMIDLIST * apidl)
567 {
568 HPROPSHEETPAGE hppages[MAX_PROPERTY_SHEET_PAGE];
569 HPROPSHEETPAGE hpage;
570 PROPSHEETHEADERW psh;
571 BOOL ret;
572 WCHAR szName[MAX_PATH] = {0};
573 HPSXA hpsx = NULL;
574 LPWSTR pFolderName;
575 IDataObject * pDataObj = NULL;
576
577 if (!PathIsDirectoryW(pwszFolder))
578 return FALSE;
579
580 pFolderName = wcsrchr(pwszFolder, L'\\');
581 if (!pFolderName)
582 return FALSE;
583
584 wcscpy(szName, pFolderName + 1);
585
586 hpage = SH_CreatePropertySheetPage("SHELL_FOLDER_GENERAL_DLG", FolderPropertiesGeneralDlg, (LPARAM)pwszFolder, NULL);
587 if (!hpage)
588 return FALSE;
589
590 ZeroMemory(&psh, sizeof(PROPSHEETHEADERW));
591 hppages[psh.nPages] = hpage;
592 psh.nPages++;
593 psh.dwSize = sizeof(PROPSHEETHEADERW);
594 psh.dwFlags = PSH_PROPTITLE;
595 psh.hwndParent = NULL;
596 psh.u3.phpage = hppages;
597 psh.pszCaption = szName;
598
599
600 if (SHCreateDataObject(pidlFolder, 1, apidl, NULL, &IID_IDataObject, (void**)&pDataObj) == S_OK)
601 {
602 hpsx = SHCreatePropSheetExtArrayEx(HKEY_CLASSES_ROOT, L"Directory", MAX_PROPERTY_SHEET_PAGE-1, pDataObj);
603 if (hpsx)
604 {
605 SHAddFromPropSheetExtArray(hpsx,
606 (LPFNADDPROPSHEETPAGE)FolderAddPropSheetPageProc,
607 (LPARAM)&psh);
608 }
609 }
610
611 ret = PropertySheetW(&psh);
612 if (pDataObj)
613 IDataObject_Release(pDataObj);
614
615 if (hpsx)
616 SHDestroyPropSheetExtArray(hpsx);
617
618 if (ret < 0)
619 return FALSE;
620 else
621 return TRUE;
622 }
623
624