BOOL SH_ShowPropertiesDialog(LPCWSTR pwszPath, LPCITEMIDLIST pidlFolder, LPCITEMIDLIST *apidl) { HPSXA hpsxa[3] = {NULL, NULL, NULL}; CComObject<CFileDefExt> *pFileDefExt = NULL; TRACE("SH_ShowPropertiesDialog entered filename %s\n", debugstr_w(pwszPath)); if (pwszPath == NULL || !wcslen(pwszPath)) return FALSE; HPROPSHEETPAGE hppages[MAX_PROPERTY_SHEET_PAGE]; memset(hppages, 0x0, sizeof(HPROPSHEETPAGE) * MAX_PROPERTY_SHEET_PAGE); /* Make a copy of path */ WCHAR wszPath[MAX_PATH]; StringCbCopyW(wszPath, sizeof(wszPath), pwszPath); /* remove trailing \\ at the end of path */ PathRemoveBackslashW(wszPath); /* Handle drives */ if (PathIsRootW(wszPath)) return SH_ShowDriveProperties(wszPath, pidlFolder, apidl); /* Handle files and folders */ PROPSHEETHEADERW Header; memset(&Header, 0x0, sizeof(PROPSHEETHEADERW)); Header.dwSize = sizeof(PROPSHEETHEADERW); Header.dwFlags = PSH_NOCONTEXTHELP | PSH_PROPTITLE; Header.phpage = hppages; Header.pszCaption = PathFindFileNameW(wszPath); CComPtr<IDataObject> pDataObj; HRESULT hr = SHCreateDataObject(pidlFolder, 1, apidl, NULL, IID_IDataObject, (LPVOID *)&pDataObj); if (SUCCEEDED(hr)) { hr = CComObject<CFileDefExt>::CreateInstance(&pFileDefExt); if (SUCCEEDED(hr)) { pFileDefExt->AddRef(); // CreateInstance returns object with 0 ref count hr = pFileDefExt->Initialize(pidlFolder, pDataObj, NULL); if (SUCCEEDED(hr)) { hr = pFileDefExt->AddPages(AddPropSheetPageCallback, (LPARAM)&Header); if (FAILED(hr)) ERR("AddPages failed\n"); } else ERR("Initialize failed\n"); } LoadPropSheetHandlers(wszPath, &Header, MAX_PROPERTY_SHEET_PAGE - 1, hpsxa, pDataObj); } INT_PTR Result = PropertySheetW(&Header); for (UINT i = 0; i < 3; ++i) if (hpsxa[i]) SHDestroyPropSheetExtArray(hpsxa[i]); if (pFileDefExt) pFileDefExt->Release(); return (Result != -1); }
/************************************************************************* * PathIsRoot [SHELL32.29] */ BOOL WINAPI PathIsRootAW(LPCVOID lpszPath) { if (SHELL_OsIsUnicode()) return PathIsRootW(lpszPath); return PathIsRootA(lpszPath); }