Cast To Device context menu in Win10

The Cast To Device function in Windows 10 is a sorry, broken mess.

I've taken to disabling it with disable_context_menus in DOpus (it's {7AD84985-87B4-4a16-BE58-8B72A5B390F7} if anyone wants to know). Otherwise it has a tendency to lock up DOpus completely, requiring a kill and a restart of DOpus... after which, Cast To Device magically works again, although it won't always list my devices!

But anyway, I'm not reporting a bug as such, as I don't think it's DOpus' place to fix Windows bugs, especially for something MS keep changing every update. And it's easy enough to disable either in DOpus or Windows.

It's just odd though how different this menu item is on File Explorer and DOpus. On Explorer, it shows everything, including bluetooth and Amazon Fire devices - (i.e. everything you get when you use "Add a device" in Windows 10 settings). On DOpus, the exact same context menu with the exact same GUID only shows DLNA devices (i.e. my TV)... the way it did in Windows 7.

Is there a particular reason why functionality is so different here...? :thinking:

A picture speaks a thousand words

The Explorer context menu is dynamic and shows devices as they appear and disappear. Perhaps Directory Opus doesn't support this?

Are you running the whole Opus process elevated or anything like that?

No, it's not elevated. I did just try running it as administrator, and didn't see any difference.

The more I look at this the more I think it has nothing to do with devices or anything like that. DOpus is probably just showing the context menu it gets on its initial query. File Explorer pauses a moment while it scans for other devices, then adds them to the already-open context menu. For that second, both DOpus and Explorer are identical.

Have you ever come across anything else that can manipulate a context menu that is already open, Leo? Is DOpus aware that handlers can do this?

(Apologies on my terminology. It's probably terrible and confusing as I don't know what these things are properly called.)

Not that I'm aware of.

I don't think we are really involved in building that menu; we just ask the shell extension which items it wants to add and display whatever it comes back with.

On my own system, I see the same two devices (a DLNA receiver and a DLNA television) in both Opus and Explorer.

Your two screenshots look like two very different menus, not just with the Cast To part, but with things like the VLC menu items being missing from Explorer's menus and present in the Opus ones.

Is the same file, in the same location, being right-clicked in both cases?

Not that I'm aware of.

I don't think we are really involved in building that menu; we just ask the shell extension which items it wants to add and display whatever it comes back with.

On my own system, I see the same two devices (a DLNA receiver and a DLNA television) in both Opus and Explorer.

On mine, it also scans for Bluetooth devices and puts them in. Not just ones I'm paired to: some of that stuff shown on the pic isn't even mine. While the menu is open, it scans both my network and bluetooth and adds everything it finds as it finds them.

I'm running the April update of Win10 (1803) just for reference.

Your two screenshots look like two very different menus, not just with the Cast To part, but with things like the VLC menu items being missing from Explorer's menus and present in the Opus ones.
Is the same file, in the same location, being right-clicked in both cases?

The files are indeed different in that picture, but one was in a DOpus file collection. I've gone back and now compared the exact same files, but it made no difference, so not worth updating the pictures.

The VLC entries come from here, but I did not set them myself. I have no idea why it's not the same for Explorer.

We only build the menu once, so whatever Explorer returns in the initial enumeration is what we’ll show. We don’t have a mechanism for context menus to update their content dynamically while they’re open - I’m not even sure how that would be possible.

Thanks for confirming; that's what I suspected looking at how both managers were opening the menu.

Is it possible then that the Cast To Device menu handler is deadlocking Directory Opus somehow?

We have a whole FAQ on how to debug lock ups due to context menu extensions, so yes, certainly possible.