Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows Explorer IShellFolderViewDual::SelectItem usage

I'm writing some code will automate selection of Window Explorer(explorer.exe) items. And I found two methods that might help:

HRESULT SelectItem(
  [in]  VARIANT *pvfi,
  [in]  int dwFlags
);
// from http://msdn.microsoft.com/en-us/library/windows/desktop/dd894079(v=vs.85).aspx

HRESULT SelectItemRelative(
  [in]  int iRelative
);
// from http://msdn.microsoft.com/en-us/library/windows/desktop/bb774966(v=vs.85).aspx

I've tried SelectItemRelative and it works perfectly; next item in explorer is selected when I pass 1 as argument. The method is self-explanatory

Now, I don't quite get SelectItem, it takes a VARIANT and an int. According to MSDN, the int flag tells the method what kind of selection to make, and that's all, no explanation on what VARIANT is.

What should I pass for VARIANT *pvfi?

like image 469
tom91136 Avatar asked Feb 13 '26 09:02

tom91136


2 Answers

IShellFolderViewDual is a dual to the (long gone IIRC) IShellFolderView. Some vestigial documentation remains. Someone has been a fan of quantum physics, it seems.

The variant should carry a VT_UNKNOWN pointing to the FolderItem instance of the item you wish to change the selection of. Then, the selection flags are as follows:

  • 0 (SVSI_DESELECT) deselect
  • 1 (SVSI_SELECT) select
  • 3 (SVSI_EDIT) put the item in edit mode
  • 4 (SVSI_DESELECTOTHERS) deselect all bu the specified item
  • 8 (SVSI_ENSUREVISIBLE) ensure that the item is visible in the view (scrollthe view)
  • 16 (SVSI_FOCUSED) give the item the focus
like image 175
Kuba hasn't forgotten Monica Avatar answered Feb 15 '26 23:02

Kuba hasn't forgotten Monica


For VARIANT you may pass LPCITEMIDLIST of the item.

like image 38
user2120666 Avatar answered Feb 15 '26 22:02

user2120666



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!