I've implemented my own File Dialog using the IFileDialog interface, and I am adding Places to the file dialog. I need to change the displayed name of a place to my own text, because if I have two places that happen to have the same name, they are impossible to tell apart. For example:
However, Adding a place only shows the last folder name - so both these places appear under the "Application Links" heading as "MyAppName". Obviously I need to differentiate between these - ideally I would like the Place's name to be displayed.
My code to add a single Place is as follows (error checking removed for clarity):
// Code above here sets nameW to the Place name, and pathW to its full path
// These are both CStringW variables
// Create the IShellItem for the folder
CComPtr<IShellItem> folder;
SHCreateItemFromParsingName(pathW, NULL, IID_PPV_ARGS(&folder);
// This section is trying to change what is displayed... but doesn't work!
PROPVARIANT pv = {0};
PropVariantInit(&pv);
pv.vt = VT_LPWSTR;
pv.pwszVal = nameW.GetBuffer();
// Here, I have tried various other properties such as PKEY_FileDescription, PKEY_FolderNameDisplay, etc.
SHSetTemporaryPropertyForItem(folder, PKEY_FileName, pv);
// Add the place
_FileDialog->AddPlace(folder, FDAP_TOP);
Can anyone tell me if / how I can do this? Thanks!
Per the AddPlace() documentation:
SHSetTemporaryPropertyForItem
can be used to set a temporaryPKEY_ItemNameDisplay
property on the item represented by thepsi
parameter. The value for this property will be used in place of the item's UI name.
So, change PKEY_FileName
to PKEY_ItemNameDisplay
instead.