Skip to content

Refresh Explorer folder windows on shell change notifications - #168

Open
josuave wants to merge 3 commits into
masterfrom
claude/fix-explorer-refresh
Open

Refresh Explorer folder windows on shell change notifications#168
josuave wants to merge 3 commits into
masterfrom
claude/fix-explorer-refresh

Conversation

@josuave

@josuave josuave commented Aug 19, 2026

Copy link
Copy Markdown
Collaborator

Fixes #434 — Explorer folder windows stop auto-refreshing (create/rename/copy/delete require a manual F5) whenever Cairo is running as the shell.

Testing

  • Manually verified against a local Cairo build with Cairo set as shell:
    • Create file/folder — appears without F5
    • Rename file — new name shows immediately
    • Copy/paste into folder — appears immediately
    • Delete file — disappears immediately
    • Move file between two open Explorer windows — both update

Becoming the OS shell window (SetShellWindow, required for shell-mode
operation) stops Explorer's own folder view windows from receiving
shell-level change notifications, since that delivery path is
restricted to whichever process the OS currently trusts as "the
shell". Work around this by registering for the same notifications
at interrupt level (not subject to that restriction) and manually
refreshing any open Explorer window browsing an affected folder via
the Shell.Application COM automation object.

Fixes cairoshell/cairoshell#434
@josuave
josuave requested a review from dremin August 20, 2026 00:00
@josuave josuave self-assigned this Aug 20, 2026
josuave added 2 commits August 19, 2026 20:16
These are documented in shlobj_core.h (Shell32.lib) and exported by
name from Shell32.dll since Windows 10, contrary to the prior comment
— no need for the ordinal EntryPoint workaround from pre-documentation
era shell programming.
- SHChangeNotifyRegister returns a ULONG registration ID (not a
  handle); SHChangeNotifyDeregister takes a ULONG. Both were
  declared as IntPtr, which happened to work on x64 by register-
  passing coincidence but didn't match the documented contract.
- SHCNE's underlying type was C# long (64-bit); the native fEvents
  parameter is LONG (32-bit).
- SHChangeNotification_Lock's dwProcId parameter must be the
  notification message's lParam when registered with
  SHCNRF_NewDelivery (as this code does), not a hardcoded 0 — per
  the function's documented remarks.

Also corrects a comment that called SHChangeNotification_Lock/Unlock
"undocumented, ordinal-exported" — they're documented in
shlobj_core.h and exported by name from Shell32.dll.
@josuave
josuave marked this pull request as draft August 20, 2026 00:30
@josuave josuave closed this Aug 20, 2026
@josuave josuave reopened this Aug 20, 2026
@josuave
josuave marked this pull request as ready for review August 20, 2026 01:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant