1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101
|
/*
* Control panel folder
*
* Copyright 2003 Martin Fuchs
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "wine/port.h"
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <stdio.h>
#define COBJMACROS
#define NONAMELESSUNION
#include "winerror.h"
#include "windef.h"
#include "winbase.h"
#include "winreg.h"
#include "wingdi.h"
#include "winuser.h"
#include "ole2.h"
#include "shlguid.h"
#include "commctrl.h"
#include "cpanel.h"
#include "pidl.h"
#include "undocshell.h"
#include "shell32_main.h"
#include "shresdef.h"
#include "shlwapi.h"
#include "wine/debug.h"
#include "debughlp.h"
#include "shfldr.h"
WINE_DEFAULT_DEBUG_CHANNEL(shell);
/***********************************************************************
* control panel implementation in shell namespace
*/
typedef struct {
IShellFolder2 IShellFolder2_iface;
IPersistFolder2 IPersistFolder2_iface;
IShellExecuteHookW IShellExecuteHookW_iface;
IShellExecuteHookA IShellExecuteHookA_iface;
LONG ref;
IUnknown *pUnkOuter; /* used for aggregation */
/* both paths are parsible from the desktop */
LPITEMIDLIST pidlRoot; /* absolute pidl */
int dwAttributes; /* attributes returned by GetAttributesOf FIXME: use it */
} ICPanelImpl;
static const IShellFolder2Vtbl vt_ShellFolder2;
static const IPersistFolder2Vtbl vt_PersistFolder2;
static const IShellExecuteHookWVtbl vt_ShellExecuteHookW;
static const IShellExecuteHookAVtbl vt_ShellExecuteHookA;
static inline ICPanelImpl *impl_from_IShellFolder2(IShellFolder2 *iface)
{
return CONTAINING_RECORD(iface, ICPanelImpl, IShellFolder2_iface);
}
static inline ICPanelImpl *impl_from_IPersistFolder2(IPersistFolder2 *iface)
{
return CONTAINING_RECORD(iface, ICPanelImpl, IPersistFolder2_iface);
}
static inline ICPanelImpl *impl_from_IShellExecuteHookW(IShellExecuteHookW *iface)
{
return CONTAINING_RECORD(iface, ICPanelImpl, IShellExecuteHookW_iface);
}
static inline ICPanelImpl *impl_from_IShellExecuteHookA(IShellExecuteHookA *iface)
{
return CONTAINING_RECORD(iface, ICPanelImpl, IShellExecuteHookA_iface);
}
/***********************************************************************
* IShellFolder [ControlPanel] implementation
*/
static const shvheader ControlPanelSFHeader[] = {
{IDS_SHV_COLUMN8, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 15},/*FIXME*/
{IDS_SHV_COLUMN9, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_LEFT, 80},/*FIXME*/
};
#define CONROLPANELSHELLVIEWCOLUMNS 2
/**************************************************************************
* IControlPanel_Constructor
*/
HRESULT WINAPI IControlPanel_Constructor(IUnknown* pUnkOuter, REFIID riid, LPVOID * ppv)
{
ICPanelImpl *sf;
TRACE("unkOut=%p %s\n", pUnkOuter, shdebugstr_guid(riid));
if (!ppv)
return E_POINTER;
if (pUnkOuter && !IsEqualIID (riid, &IID_IUnknown))
return CLASS_E_NOAGGREGATION;
sf = LocalAlloc(LMEM_ZEROINIT, sizeof(ICPanelImpl));
if (!sf)
return E_OUTOFMEMORY;
sf->ref = 1;
sf->IShellFolder2_iface.lpVtbl = &vt_ShellFolder2;
sf->IPersistFolder2_iface.lpVtbl = &vt_PersistFolder2;
sf->IShellExecuteHookW_iface.lpVtbl = &vt_ShellExecuteHookW;
sf->IShellExecuteHookA_iface.lpVtbl = &vt_ShellExecuteHookA;
sf->pidlRoot = _ILCreateControlPanel(); /* my qualified pidl */
sf->pUnkOuter = pUnkOuter ? pUnkOuter : (IUnknown *)&sf->IShellFolder2_iface;
if (FAILED(IShellFolder2_QueryInterface(&sf->IShellFolder2_iface, riid, ppv))) {
IShellFolder2_Release(&sf->IShellFolder2_iface);
return E_NOINTERFACE;
}
IShellFolder2_Release(&sf->IShellFolder2_iface);
TRACE("--(%p)\n", sf);
return S_OK;
}
/**************************************************************************
* ISF_ControlPanel_fnQueryInterface
*
* NOTES supports not IPersist/IPersistFolder
*/
static HRESULT WINAPI ISF_ControlPanel_fnQueryInterface(IShellFolder2 *iface, REFIID riid,
void **ppvObject)
{
ICPanelImpl *This = impl_from_IShellFolder2(iface);
TRACE("(%p)->(%s,%p)\n", This, shdebugstr_guid(riid), ppvObject);
*ppvObject = NULL;
if (IsEqualIID(riid, &IID_IUnknown) ||
IsEqualIID(riid, &IID_IShellFolder) || IsEqualIID(riid, &IID_IShellFolder2))
*ppvObject = &This->IShellFolder2_iface;
else if (IsEqualIID(riid, &IID_IPersist) ||
IsEqualIID(riid, &IID_IPersistFolder) || IsEqualIID(riid, &IID_IPersistFolder2))
*ppvObject = &This->IPersistFolder2_iface;
else if (IsEqualIID(riid, &IID_IShellExecuteHookW))
*ppvObject = &This->IShellExecuteHookW_iface;
else if (IsEqualIID(riid, &IID_IShellExecuteHookA))
*ppvObject = &This->IShellExecuteHookA_iface;
if (*ppvObject) {
IUnknown_AddRef((IUnknown *)(*ppvObject));
TRACE("-- Interface:(%p)->(%p)\n", ppvObject, *ppvObject);
return S_OK;
}
TRACE("-- Interface: E_NOINTERFACE\n");
return E_NOINTERFACE;
}
static ULONG WINAPI ISF_ControlPanel_fnAddRef(IShellFolder2 *iface)
{
ICPanelImpl *This = impl_from_IShellFolder2(iface);
ULONG refCount = InterlockedIncrement(&This->ref);
TRACE("(%p)->(count=%u)\n", This, refCount - 1);
return refCount;
}
static ULONG WINAPI ISF_ControlPanel_fnRelease(IShellFolder2 *iface)
{
ICPanelImpl *This = impl_from_IShellFolder2(iface);
ULONG refCount = InterlockedDecrement(&This->ref);
TRACE("(%p)->(count=%u)\n", This, refCount + 1);
if (!refCount) {
TRACE("-- destroying IShellFolder(%p)\n", This);
SHFree(This->pidlRoot);
LocalFree(This);
}
return refCount;
}
/**************************************************************************
* ISF_ControlPanel_fnParseDisplayName
*/
static HRESULT WINAPI ISF_ControlPanel_fnParseDisplayName(IShellFolder2 *iface, HWND hwndOwner,
LPBC pbc, LPOLESTR lpszDisplayName, DWORD *pchEaten, LPITEMIDLIST *ppidl,
DWORD *pdwAttributes)
{
ICPanelImpl *This = impl_from_IShellFolder2(iface);
HRESULT hr = E_INVALIDARG;
FIXME("(%p)->(HWND=%p,%p,%p=%s,%p,pidl=%p,%p)\n",
This, hwndOwner, pbc, lpszDisplayName, debugstr_w(lpszDisplayName), pchEaten, ppidl, pdwAttributes);
*ppidl = 0;
if (pchEaten)
*pchEaten = 0;
TRACE("(%p)->(-- ret=0x%08x)\n", This, hr);
return hr;
}
static LPITEMIDLIST _ILCreateCPanelApplet(LPCSTR name, LPCSTR displayName,
LPCSTR comment, int iconIdx)
{
PIDLCPanelStruct *p;
LPITEMIDLIST pidl;
PIDLDATA tmp;
int size0 = (char*)tmp.u.cpanel.szName-(char*)&tmp.u.cpanel;
int size = size0;
int l;
tmp.type = PT_CPLAPPLET;
tmp.u.cpanel.dummy = 0;
tmp.u.cpanel.iconIdx = iconIdx;
l = strlen(name);
size += l+1;
tmp.u.cpanel.offsDispName = l+1;
l = strlen(displayName);
size += l+1;
tmp.u.cpanel.offsComment = tmp.u.cpanel.offsDispName+1+l;
l = strlen(comment);
size += l+1;
pidl = SHAlloc(size+4);
if (!pidl)
return NULL;
pidl->mkid.cb = size+2;
memcpy(pidl->mkid.abID, &tmp, 2+size0);
p = &((PIDLDATA*)pidl->mkid.abID)->u.cpanel;
strcpy(p->szName, name);
strcpy(p->szName+tmp.u.cpanel.offsDispName, displayName);
strcpy(p->szName+tmp.u.cpanel.offsComment, comment);
*(WORD*)((char*)pidl+(size+2)) = 0;
pcheck(pidl);
return pidl;
}
/**************************************************************************
* _ILGetCPanelPointer()
* gets a pointer to the control panel struct stored in the pidl
*/
static PIDLCPanelStruct* _ILGetCPanelPointer(LPCITEMIDLIST pidl)
{
LPPIDLDATA pdata = _ILGetDataPointer(pidl);
if (pdata && pdata->type==PT_CPLAPPLET)
return &pdata->u.cpanel;
return NULL;
}
/**************************************************************************
* ISF_ControlPanel_fnEnumObjects
*/
static BOOL SHELL_RegisterCPanelApp(IEnumIDListImpl *list, LPCSTR path)
{
LPITEMIDLIST pidl;
CPlApplet* applet;
CPanel panel;
CPLINFO info;
unsigned i;
int iconIdx;
char displayName[MAX_PATH];
char comment[MAX_PATH];
WCHAR wpath[MAX_PATH];
MultiByteToWideChar(CP_ACP, 0, path, -1, wpath, MAX_PATH);
list_init( &panel.applets );
applet = Control_LoadApplet(0, wpath, &panel);
if (applet)
{
for(i=0; i<applet->count; ++i)
{
WideCharToMultiByte(CP_ACP, 0, applet->info[i].name, -1, displayName, MAX_PATH, 0, 0);
WideCharToMultiByte(CP_ACP, 0, applet->info[i].info, -1, comment, MAX_PATH, 0, 0);
applet->proc(0, CPL_INQUIRE, i, (LPARAM)&info);
if (info.idIcon > 0)
iconIdx = -info.idIcon; /* negative icon index instead of icon number */
else
iconIdx = 0;
pidl = _ILCreateCPanelApplet(path, displayName, comment, iconIdx);
if (pidl)
AddToEnumList(list, pidl);
}
Control_UnloadApplet(applet);
}
return TRUE;
}
static int SHELL_RegisterRegistryCPanelApps(IEnumIDListImpl *list, HKEY hkey_root, LPCSTR szRepPath)
{
char name[MAX_PATH];
char value[MAX_PATH];
HKEY hkey;
int cnt = 0;
if (RegOpenKeyA(hkey_root, szRepPath, &hkey) == ERROR_SUCCESS)
{
int idx = 0;
for(;; ++idx)
{
DWORD nameLen = MAX_PATH;
DWORD valueLen = MAX_PATH;
if (RegEnumValueA(hkey, idx, name, &nameLen, NULL, NULL, (LPBYTE)value, &valueLen) != ERROR_SUCCESS)
break;
if (SHELL_RegisterCPanelApp(list, value))
++cnt;
}
RegCloseKey(hkey);
}
return cnt;
}
static int SHELL_RegisterCPanelFolders(IEnumIDListImpl *list, HKEY hkey_root, LPCSTR szRepPath)
{
char name[MAX_PATH];
HKEY hkey;
int cnt = 0;
if (RegOpenKeyA(hkey_root, szRepPath, &hkey) == ERROR_SUCCESS)
{
int idx = 0;
for(;; ++idx)
{
if (RegEnumKeyA(hkey, idx, name, MAX_PATH) != ERROR_SUCCESS)
break;
if (*name == '{')
{
LPITEMIDLIST pidl = _ILCreateGuidFromStrA(name);
if (pidl && AddToEnumList(list, pidl))
++cnt;
}
}
RegCloseKey(hkey);
}
return cnt;
}
/**************************************************************************
* CreateCPanelEnumList()
*/
static BOOL CreateCPanelEnumList(IEnumIDListImpl *list, DWORD dwFlags)
{
CHAR szPath[MAX_PATH];
WIN32_FIND_DATAA wfd;
HANDLE hFile;
TRACE("(%p)->(flags=0x%08x)\n", list, dwFlags);
/* enumerate control panel folders */
if (dwFlags & SHCONTF_FOLDERS)
SHELL_RegisterCPanelFolders(list, HKEY_LOCAL_MACHINE,
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ControlPanel\\NameSpace");
/* enumerate the control panel applets */
if (dwFlags & SHCONTF_NONFOLDERS)
{
LPSTR p;
GetSystemDirectoryA(szPath, MAX_PATH);
p = PathAddBackslashA(szPath);
strcpy(p, "*.cpl");
TRACE("-- (%p)-> enumerate SHCONTF_NONFOLDERS of %s\n", list, debugstr_a(szPath));
hFile = FindFirstFileA(szPath, &wfd);
if (hFile != INVALID_HANDLE_VALUE)
{
do
{
if (!(dwFlags & SHCONTF_INCLUDEHIDDEN) && (wfd.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN))
continue;
if (!(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
strcpy(p, wfd.cFileName);
SHELL_RegisterCPanelApp(list, szPath);
}
} while(FindNextFileA(hFile, &wfd));
FindClose(hFile);
}
SHELL_RegisterRegistryCPanelApps(list, HKEY_LOCAL_MACHINE,
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Control Panel\\Cpls");
SHELL_RegisterRegistryCPanelApps(list, HKEY_CURRENT_USER,
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Control Panel\\Cpls");
}
return TRUE;
}
/**************************************************************************
* ISF_ControlPanel_fnEnumObjects
*/
static HRESULT WINAPI ISF_ControlPanel_fnEnumObjects(IShellFolder2 *iface, HWND hwndOwner,
DWORD dwFlags, LPENUMIDLIST *ppEnumIDList)
{
ICPanelImpl *This = impl_from_IShellFolder2(iface);
IEnumIDListImpl *list;
TRACE("(%p)->(HWND=%p flags=0x%08x pplist=%p)\n", This, hwndOwner, dwFlags, ppEnumIDList);
if (!(list = IEnumIDList_Constructor()))
return E_OUTOFMEMORY;
CreateCPanelEnumList(list, dwFlags);
*ppEnumIDList = &list->IEnumIDList_iface;
TRACE("--(%p)->(new ID List: %p)\n", This, *ppEnumIDList);
return S_OK;
}
/**************************************************************************
* ISF_ControlPanel_fnBindToObject
*/
static HRESULT WINAPI ISF_ControlPanel_fnBindToObject(IShellFolder2 *iface, LPCITEMIDLIST pidl,
LPBC pbcReserved, REFIID riid, void **ppvOut)
{
ICPanelImpl *This = impl_from_IShellFolder2(iface);
TRACE("(%p)->(pidl=%p,%p,%s,%p)\n", This, pidl, pbcReserved, shdebugstr_guid(riid), ppvOut);
return SHELL32_BindToChild(This->pidlRoot, NULL, pidl, riid, ppvOut);
}
/**************************************************************************
* ISF_ControlPanel_fnBindToStorage
*/
static HRESULT WINAPI ISF_ControlPanel_fnBindToStorage(IShellFolder2 *iface, LPCITEMIDLIST pidl,
LPBC pbcReserved, REFIID riid, void **ppvOut)
{
ICPanelImpl *This = impl_from_IShellFolder2(iface);
FIXME("(%p)->(pidl=%p,%p,%s,%p) stub\n", This, pidl, pbcReserved, shdebugstr_guid(riid), ppvOut);
*ppvOut = NULL;
return E_NOTIMPL;
}
/**************************************************************************
* ISF_ControlPanel_fnCompareIDs
*/
static HRESULT WINAPI ISF_ControlPanel_fnCompareIDs(IShellFolder2 *iface, LPARAM lParam,
LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
{
ICPanelImpl *This = impl_from_IShellFolder2(iface);
int nReturn;
TRACE("(%p)->(0x%08lx,pidl1=%p,pidl2=%p)\n", This, lParam, pidl1, pidl2);
nReturn = SHELL32_CompareIDs(&This->IShellFolder2_iface, lParam, pidl1, pidl2);
TRACE("-- %i\n", nReturn);
return nReturn;
}
/**************************************************************************
* ISF_ControlPanel_fnCreateViewObject
*/
static HRESULT WINAPI ISF_ControlPanel_fnCreateViewObject(IShellFolder2 *iface, HWND hwndOwner,
REFIID riid, void **ppvOut)
{
ICPanelImpl *This = impl_from_IShellFolder2(iface);
LPSHELLVIEW pShellView;
HRESULT hr = E_INVALIDARG;
TRACE("(%p)->(hwnd=%p,%s,%p)\n", This, hwndOwner, shdebugstr_guid(riid), ppvOut);
if (ppvOut) {
*ppvOut = NULL;
if (IsEqualIID(riid, &IID_IDropTarget)) {
WARN("IDropTarget not implemented\n");
hr = E_NOTIMPL;
} else if (IsEqualIID(riid, &IID_IContextMenu)) {
WARN("IContextMenu not implemented\n");
hr = E_NOTIMPL;
} else if (IsEqualIID(riid, &IID_IShellView)) {
pShellView = IShellView_Constructor((IShellFolder *) iface);
if (pShellView) {
hr = IShellView_QueryInterface(pShellView, riid, ppvOut);
IShellView_Release(pShellView);
}
}
}
TRACE("--(%p)->(interface=%p)\n", This, ppvOut);
return hr;
}
/**************************************************************************
* ISF_ControlPanel_fnGetAttributesOf
*/
static HRESULT WINAPI ISF_ControlPanel_fnGetAttributesOf(IShellFolder2 *iface, UINT cidl,
LPCITEMIDLIST *apidl, DWORD *rgfInOut)
{
ICPanelImpl *This = impl_from_IShellFolder2(iface);
HRESULT hr = S_OK;
TRACE("(%p)->(cidl=%d apidl=%p mask=%p (0x%08x))\n",
This, cidl, apidl, rgfInOut, rgfInOut ? *rgfInOut : 0);
if (!rgfInOut)
return E_INVALIDARG;
if (cidl && !apidl)
return E_INVALIDARG;
if (*rgfInOut == 0)
*rgfInOut = ~0;
while(cidl > 0 && *apidl) {
pdump(*apidl);
SHELL32_GetItemAttributes(&This->IShellFolder2_iface, *apidl, rgfInOut);
apidl++;
cidl--;
}
/* make sure SFGAO_VALIDATE is cleared, some apps depend on that */
*rgfInOut &= ~SFGAO_VALIDATE;
TRACE("-- result=0x%08x\n", *rgfInOut);
return hr;
}
/**************************************************************************
* ISF_ControlPanel_fnGetUIObjectOf
*
* PARAMETERS
* HWND hwndOwner, //[in ] Parent window for any output
* UINT cidl, //[in ] array size
* LPCITEMIDLIST* apidl, //[in ] simple pidl array
* REFIID riid, //[in ] Requested Interface
* UINT* prgfInOut, //[ ] reserved
* LPVOID* ppvObject) //[out] Resulting Interface
*
*/
static HRESULT WINAPI ISF_ControlPanel_fnGetUIObjectOf(IShellFolder2 *iface, HWND hwndOwner,
UINT cidl, LPCITEMIDLIST *apidl, REFIID riid, UINT *prgfInOut, void **ppvOut)
{
ICPanelImpl *This = impl_from_IShellFolder2(iface);
LPITEMIDLIST pidl;
IUnknown *pObj = NULL;
HRESULT hr = E_INVALIDARG;
TRACE("(%p)->(%p,%u,apidl=%p,%s,%p,%p)\n",
This, hwndOwner, cidl, apidl, shdebugstr_guid(riid), prgfInOut, ppvOut);
if (ppvOut) {
*ppvOut = NULL;
if (IsEqualIID(riid, &IID_IContextMenu) &&(cidl >= 1)) {
return ItemMenu_Constructor((IShellFolder*)iface, This->pidlRoot, apidl, cidl, riid, ppvOut);
} else if (IsEqualIID(riid, &IID_IDataObject) &&(cidl >= 1)) {
pObj = (LPUNKNOWN) IDataObject_Constructor(hwndOwner, This->pidlRoot, apidl, cidl);
hr = S_OK;
} else if (IsEqualIID(riid, &IID_IExtractIconA) &&(cidl == 1)) {
pidl = ILCombine(This->pidlRoot, apidl[0]);
pObj = (LPUNKNOWN) IExtractIconA_Constructor(pidl);
SHFree(pidl);
hr = S_OK;
} else if (IsEqualIID(riid, &IID_IExtractIconW) &&(cidl == 1)) {
pidl = ILCombine(This->pidlRoot, apidl[0]);
pObj = (LPUNKNOWN) IExtractIconW_Constructor(pidl);
SHFree(pidl);
hr = S_OK;
} else if ((IsEqualIID(riid,&IID_IShellLinkW) || IsEqualIID(riid,&IID_IShellLinkA))
&& (cidl == 1)) {
pidl = ILCombine(This->pidlRoot, apidl[0]);
hr = IShellLink_ConstructFromFile(NULL, riid, pidl, &pObj);
SHFree(pidl);
} else {
hr = E_NOINTERFACE;
}
if (SUCCEEDED(hr) && !pObj)
hr = E_OUTOFMEMORY;
*ppvOut = pObj;
}
TRACE("(%p)->hr=0x%08x\n", This, hr);
return hr;
}
/**************************************************************************
* ISF_ControlPanel_fnGetDisplayNameOf
*/
static HRESULT WINAPI ISF_ControlPanel_fnGetDisplayNameOf(IShellFolder2 *iface, LPCITEMIDLIST pidl,
DWORD dwFlags, LPSTRRET strRet)
{
ICPanelImpl *This = impl_from_IShellFolder2(iface);
CHAR szPath[MAX_PATH];
WCHAR wszPath[MAX_PATH+1]; /* +1 for potential backslash */
PIDLCPanelStruct* pcpanel;
*szPath = '\0';
TRACE("(%p)->(pidl=%p,0x%08x,%p)\n", This, pidl, dwFlags, strRet);
pdump(pidl);
if (!pidl || !strRet)
return E_INVALIDARG;
pcpanel = _ILGetCPanelPointer(pidl);
if (pcpanel) {
lstrcpyA(szPath, pcpanel->szName+pcpanel->offsDispName);
if (!(dwFlags & SHGDN_FORPARSING))
FIXME("retrieve display name from control panel app\n");
}
/* take names of special folders only if it's only this folder */
else if (_ILIsSpecialFolder(pidl)) {
BOOL bSimplePidl = _ILIsPidlSimple(pidl);
if (bSimplePidl) {
_ILSimpleGetTextW(pidl, wszPath, MAX_PATH); /* append my own path */
} else {
FIXME("special pidl\n");
}
if ((dwFlags & SHGDN_FORPARSING) && !bSimplePidl) { /* go deeper if needed */
int len = 0;
PathAddBackslashW(wszPath);
len = lstrlenW(wszPath);
if (FAILED(SHELL32_GetDisplayNameOfChild(iface, pidl, dwFlags | SHGDN_INFOLDER, wszPath + len, MAX_PATH + 1 - len)))
return E_OUTOFMEMORY;
if (!WideCharToMultiByte(CP_ACP, 0, wszPath, -1, szPath, MAX_PATH, NULL, NULL))
wszPath[0] = '\0';
}
}
strRet->uType = STRRET_CSTR;
lstrcpynA(strRet->u.cStr, szPath, MAX_PATH);
TRACE("--(%p)->(%s)\n", This, szPath);
return S_OK;
}
/**************************************************************************
* ISF_ControlPanel_fnSetNameOf
* Changes the name of a file object or subfolder, possibly changing its item
* identifier in the process.
*
* PARAMETERS
* HWND hwndOwner, //[in ] Owner window for output
* LPCITEMIDLIST pidl, //[in ] simple pidl of item to change
* LPCOLESTR lpszName, //[in ] the items new display name
* DWORD dwFlags, //[in ] SHGNO formatting flags
* LPITEMIDLIST* ppidlOut) //[out] simple pidl returned
*/
static HRESULT WINAPI ISF_ControlPanel_fnSetNameOf(IShellFolder2 *iface, HWND hwndOwner,
LPCITEMIDLIST pidl, LPCOLESTR lpName, DWORD dwFlags, LPITEMIDLIST *pPidlOut)
{
ICPanelImpl *This = impl_from_IShellFolder2(iface);
FIXME("(%p)->(%p,pidl=%p,%s,%u,%p)\n", This, hwndOwner, pidl, debugstr_w(lpName), dwFlags, pPidlOut);
return E_FAIL;
}
static HRESULT WINAPI ISF_ControlPanel_fnGetDefaultSearchGUID(IShellFolder2 *iface, GUID *pguid)
{
ICPanelImpl *This = impl_from_IShellFolder2(iface);
FIXME("(%p)\n", This);
return E_NOTIMPL;
}
static HRESULT WINAPI ISF_ControlPanel_fnEnumSearches(IShellFolder2 *iface,
IEnumExtraSearch **ppenum)
{
ICPanelImpl *This = impl_from_IShellFolder2(iface);
FIXME("(%p)\n", This);
return E_NOTIMPL;
}
static HRESULT WINAPI ISF_ControlPanel_fnGetDefaultColumn(IShellFolder2 *iface, DWORD dwRes,
ULONG *pSort, ULONG *pDisplay)
{
ICPanelImpl *This = impl_from_IShellFolder2(iface);
TRACE("(%p)\n", This);
if (pSort) *pSort = 0;
if (pDisplay) *pDisplay = 0;
return S_OK;
}
static HRESULT WINAPI ISF_ControlPanel_fnGetDefaultColumnState(IShellFolder2 *iface, UINT iColumn,
DWORD *pcsFlags)
{
ICPanelImpl *This = impl_from_IShellFolder2(iface);
TRACE("(%p)\n", This);
if (!pcsFlags || iColumn >= CONROLPANELSHELLVIEWCOLUMNS) return E_INVALIDARG;
*pcsFlags = ControlPanelSFHeader[iColumn].pcsFlags;
return S_OK;
}
static HRESULT WINAPI ISF_ControlPanel_fnGetDetailsEx(IShellFolder2 *iface, LPCITEMIDLIST pidl,
const SHCOLUMNID *pscid, VARIANT *pv)
{
ICPanelImpl *This = impl_from_IShellFolder2(iface);
FIXME("(%p)\n", This);
return E_NOTIMPL;
}
static HRESULT WINAPI ISF_ControlPanel_fnGetDetailsOf(IShellFolder2 *iface, LPCITEMIDLIST pidl,
UINT iColumn, SHELLDETAILS *psd)
{
ICPanelImpl *This = impl_from_IShellFolder2(iface);
PIDLCPanelStruct* pcpanel;
HRESULT hr;
TRACE("(%p)->(%p %i %p)\n", This, pidl, iColumn, psd);
if (!psd || iColumn >= CONROLPANELSHELLVIEWCOLUMNS)
return E_INVALIDARG;
if (!pidl) {
psd->fmt = ControlPanelSFHeader[iColumn].fmt;
psd->cxChar = ControlPanelSFHeader[iColumn].cxChar;
psd->str.uType = STRRET_CSTR;
LoadStringA(shell32_hInstance, ControlPanelSFHeader[iColumn].colnameid, psd->str.u.cStr, MAX_PATH);
return S_OK;
} else {
psd->str.u.cStr[0] = 0x00;
psd->str.uType = STRRET_CSTR;
switch(iColumn) {
case 0: /* name */
hr = IShellFolder2_GetDisplayNameOf(iface, pidl, SHGDN_NORMAL | SHGDN_INFOLDER, &psd->str);
break;
case 1: /* comment */
pcpanel = _ILGetCPanelPointer(pidl);
if (pcpanel)
lstrcpyA(psd->str.u.cStr, pcpanel->szName+pcpanel->offsComment);
else
_ILGetFileType(pidl, psd->str.u.cStr, MAX_PATH);
break;
}
hr = S_OK;
}
return hr;
}
static HRESULT WINAPI ISF_ControlPanel_fnMapColumnToSCID(IShellFolder2 *iface, UINT column,
SHCOLUMNID *pscid)
{
ICPanelImpl *This = impl_from_IShellFolder2(iface);
FIXME("(%p)\n", This);
return E_NOTIMPL;
}
static const IShellFolder2Vtbl vt_ShellFolder2 =
{
ISF_ControlPanel_fnQueryInterface,
ISF_ControlPanel_fnAddRef,
ISF_ControlPanel_fnRelease,
ISF_ControlPanel_fnParseDisplayName,
ISF_ControlPanel_fnEnumObjects,
ISF_ControlPanel_fnBindToObject,
ISF_ControlPanel_fnBindToStorage,
ISF_ControlPanel_fnCompareIDs,
ISF_ControlPanel_fnCreateViewObject,
ISF_ControlPanel_fnGetAttributesOf,
ISF_ControlPanel_fnGetUIObjectOf,
ISF_ControlPanel_fnGetDisplayNameOf,
ISF_ControlPanel_fnSetNameOf,
/* ShellFolder2 */
ISF_ControlPanel_fnGetDefaultSearchGUID,
ISF_ControlPanel_fnEnumSearches,
ISF_ControlPanel_fnGetDefaultColumn,
ISF_ControlPanel_fnGetDefaultColumnState,
ISF_ControlPanel_fnGetDetailsEx,
ISF_ControlPanel_fnGetDetailsOf,
ISF_ControlPanel_fnMapColumnToSCID
};
/************************************************************************
* ICPanel_PersistFolder2_QueryInterface
*/
static HRESULT WINAPI ICPanel_PersistFolder2_QueryInterface(IPersistFolder2 * iface, REFIID iid, LPVOID * ppvObject)
{
ICPanelImpl *This = impl_from_IPersistFolder2(iface);
TRACE("(%p)\n", This);
return IShellFolder2_QueryInterface(&This->IShellFolder2_iface, iid, ppvObject);
}
/************************************************************************
* ICPanel_PersistFolder2_AddRef
*/
static ULONG WINAPI ICPanel_PersistFolder2_AddRef(IPersistFolder2 * iface)
{
ICPanelImpl *This = impl_from_IPersistFolder2(iface);
TRACE("(%p)->(count=%u)\n", This, This->ref);
return IShellFolder2_AddRef(&This->IShellFolder2_iface);
}
/************************************************************************
* ISFPersistFolder_Release
*/
static ULONG WINAPI ICPanel_PersistFolder2_Release(IPersistFolder2 * iface)
{
ICPanelImpl *This = impl_from_IPersistFolder2(iface);
TRACE("(%p)->(count=%u)\n", This, This->ref);
return IShellFolder2_Release(&This->IShellFolder2_iface);
}
/************************************************************************
* ICPanel_PersistFolder2_GetClassID
*/
static HRESULT WINAPI ICPanel_PersistFolder2_GetClassID(IPersistFolder2 * iface, CLSID * lpClassId)
{
ICPanelImpl *This = impl_from_IPersistFolder2(iface);
TRACE("(%p)\n", This);
if (!lpClassId)
return E_POINTER;
*lpClassId = CLSID_ControlPanel;
return S_OK;
}
/************************************************************************
* ICPanel_PersistFolder2_Initialize
*
* NOTES: it makes no sense to change the pidl
*/
static HRESULT WINAPI ICPanel_PersistFolder2_Initialize(IPersistFolder2 * iface, LPCITEMIDLIST pidl)
{
ICPanelImpl *This = impl_from_IPersistFolder2(iface);
TRACE("(%p)->(%p)\n", This, pidl);
return E_NOTIMPL;
}
/**************************************************************************
* IPersistFolder2_fnGetCurFolder
*/
static HRESULT WINAPI ICPanel_PersistFolder2_GetCurFolder(IPersistFolder2 * iface, LPITEMIDLIST * pidl)
{
ICPanelImpl *This = impl_from_IPersistFolder2(iface);
TRACE("(%p)->(%p)\n", This, pidl);
if (!pidl)
return E_POINTER;
*pidl = ILClone(This->pidlRoot);
return S_OK;
}
static const IPersistFolder2Vtbl vt_PersistFolder2 =
{
ICPanel_PersistFolder2_QueryInterface,
ICPanel_PersistFolder2_AddRef,
ICPanel_PersistFolder2_Release,
ICPanel_PersistFolder2_GetClassID,
ICPanel_PersistFolder2_Initialize,
ICPanel_PersistFolder2_GetCurFolder
};
HRESULT CPanel_GetIconLocationW(LPCITEMIDLIST pidl,
LPWSTR szIconFile, UINT cchMax, int* piIndex)
{
PIDLCPanelStruct* pcpanel = _ILGetCPanelPointer(pidl);
if (!pcpanel)
return E_INVALIDARG;
MultiByteToWideChar(CP_ACP, 0, pcpanel->szName, -1, szIconFile, cchMax);
*piIndex = pcpanel->iconIdx!=-1? pcpanel->iconIdx: 0;
return S_OK;
}
/**************************************************************************
* IShellExecuteHookW Implementation
*/
static HRESULT WINAPI IShellExecuteHookW_fnQueryInterface(
IShellExecuteHookW* iface, REFIID riid, void** ppvObject)
{
ICPanelImpl *This = impl_from_IShellExecuteHookW(iface);
TRACE("(%p)->(count=%u)\n", This, This->ref);
return IUnknown_QueryInterface(This->pUnkOuter, riid, ppvObject);
}
static ULONG STDMETHODCALLTYPE IShellExecuteHookW_fnAddRef(IShellExecuteHookW* iface)
{
ICPanelImpl *This = impl_from_IShellExecuteHookW(iface);
TRACE("(%p)->(count=%u)\n", This, This->ref);
return IUnknown_AddRef(This->pUnkOuter);
}
static ULONG STDMETHODCALLTYPE IShellExecuteHookW_fnRelease(IShellExecuteHookW* iface)
{
ICPanelImpl *This = impl_from_IShellExecuteHookW(iface);
TRACE("(%p)\n", This);
return IUnknown_Release(This->pUnkOuter);
}
static HRESULT WINAPI IShellExecuteHookW_fnExecute(IShellExecuteHookW *iface,
LPSHELLEXECUTEINFOW psei)
{
ICPanelImpl *This = impl_from_IShellExecuteHookW(iface);
static const WCHAR wCplopen[] = {'c','p','l','o','p','e','n','\0'};
SHELLEXECUTEINFOW sei_tmp;
PIDLCPanelStruct* pcpanel;
WCHAR path[MAX_PATH];
WCHAR params[MAX_PATH];
BOOL ret;
int l;
TRACE("(%p)->execute(%p)\n", This, psei);
if (!psei)
return E_INVALIDARG;
pcpanel = _ILGetCPanelPointer(ILFindLastID(psei->lpIDList));
if (!pcpanel)
return E_INVALIDARG;
path[0] = '\"';
/* Return value from MultiByteToWideChar includes terminating NUL, which
* compensates for the starting double quote we just put in */
l = MultiByteToWideChar(CP_ACP, 0, pcpanel->szName, -1, path+1, MAX_PATH-1);
/* pass applet name to Control_RunDLL to distinguish between applets in one .cpl file */
path[l++] = '"';
path[l] = '\0';
MultiByteToWideChar(CP_ACP, 0, pcpanel->szName+pcpanel->offsDispName, -1, params, MAX_PATH);
sei_tmp = *psei;
sei_tmp.lpFile = path;
sei_tmp.lpParameters = params;
sei_tmp.fMask &= ~SEE_MASK_INVOKEIDLIST;
sei_tmp.lpVerb = wCplopen;
ret = ShellExecuteExW(&sei_tmp);
if (ret)
return S_OK;
else
return S_FALSE;
}
static const IShellExecuteHookWVtbl vt_ShellExecuteHookW =
{
IShellExecuteHookW_fnQueryInterface,
IShellExecuteHookW_fnAddRef,
IShellExecuteHookW_fnRelease,
IShellExecuteHookW_fnExecute
};
/**************************************************************************
* IShellExecuteHookA Implementation
*/
static HRESULT WINAPI IShellExecuteHookA_fnQueryInterface(IShellExecuteHookA* iface, REFIID riid, void** ppvObject)
{
ICPanelImpl *This = impl_from_IShellExecuteHookA(iface);
TRACE("(%p)->(count=%u)\n", This, This->ref);
return IUnknown_QueryInterface(This->pUnkOuter, riid, ppvObject);
}
static ULONG STDMETHODCALLTYPE IShellExecuteHookA_fnAddRef(IShellExecuteHookA* iface)
{
ICPanelImpl *This = impl_from_IShellExecuteHookA(iface);
TRACE("(%p)->(count=%u)\n", This, This->ref);
return IUnknown_AddRef(This->pUnkOuter);
}
static ULONG STDMETHODCALLTYPE IShellExecuteHookA_fnRelease(IShellExecuteHookA* iface)
{
ICPanelImpl *This = impl_from_IShellExecuteHookA(iface);
TRACE("(%p)\n", This);
return IUnknown_Release(This->pUnkOuter);
}
static HRESULT WINAPI IShellExecuteHookA_fnExecute(IShellExecuteHookA *iface,
LPSHELLEXECUTEINFOA psei)
{
ICPanelImpl *This = impl_from_IShellExecuteHookA(iface);
SHELLEXECUTEINFOA sei_tmp;
PIDLCPanelStruct* pcpanel;
char path[MAX_PATH];
BOOL ret;
TRACE("(%p)->execute(%p)\n", This, psei);
if (!psei)
return E_INVALIDARG;
pcpanel = _ILGetCPanelPointer(ILFindLastID(psei->lpIDList));
if (!pcpanel)
return E_INVALIDARG;
path[0] = '\"';
lstrcpyA(path+1, pcpanel->szName);
/* pass applet name to Control_RunDLL to distinguish between applets in one .cpl file */
lstrcatA(path, "\" ");
lstrcatA(path, pcpanel->szName+pcpanel->offsDispName);
sei_tmp = *psei;
sei_tmp.lpFile = path;
sei_tmp.fMask &= ~SEE_MASK_INVOKEIDLIST;
ret = ShellExecuteExA(&sei_tmp);
if (ret)
return S_OK;
else
return S_FALSE;
}
static const IShellExecuteHookAVtbl vt_ShellExecuteHookA =
{
IShellExecuteHookA_fnQueryInterface,
IShellExecuteHookA_fnAddRef,
IShellExecuteHookA_fnRelease,
IShellExecuteHookA_fnExecute
};
|