1
2
3
4
5
6
7
8
9
10
11
# VirtualDesktopAccessor C port
[`VirtualDesktopAccessor.c`](VirtualDesktopAccessor.c), [`notifications.c`](notifications.c), and [`virtualdesktopaccessor.h`](virtualdesktopaccessor.h) adapt the virtual-desktop COM code from [Ciantic/VirtualDesktopAccessor](https://github.com/Ciantic/VirtualDesktopAccessor). **Original author: Jari Otto Oskari Pennanen (© 2015–2023).** Keep the original [MIT license and copyright notice](LICENSE.txt) with the source and binaries containing it. The library has no hotkey action names; those live in [`plugins/vd/plugin.c`](../../plugins/vd/plugin.c).
The DLL exports the upstream desktop/window queries and movement functions, desktop IDs, UTF-8 names, creation/removal/reordering, window/app pinning, notification registration, and `RestartVirtualDesktopAccessor`. C signatures are in the header. `VDACreateDesktop()` is the C identifier because Win32 already defines `CreateDesktopA/W`; its **DLL export is `CreateDesktop`**. Indices are zero-based. Most operations return `1` on success, `0` for a false query (or an unavailable desktop name), and `-1` on error; ID queries return a zero GUID on error. `GetDesktopName` needs an output buffer including the terminating NUL; `SetDesktopName` takes UTF-8. `RestartVirtualDesktopAccessor` is a no-op because this implementation opens fresh COM proxies for each call.
`RegisterPostMessageHook(hwnd, message)` posts a desktop-switch notification to each registered window (`wParam` = old index, `lParam` = new index). It returns `1` or `-1`. `UnregisterPostMessageHook(hwnd)` removes that window. **Unregister all listeners before unloading the DLL**; COM callbacks run on a background thread. If Explorer refuses to unregister a callback, the DLL retains a module reference rather than unloading callback code still in use. The notification worker attempts to reconnect after Explorer restarts, but missed transitions are not replayed.
Build from an x64 Visual Studio Developer Command Prompt with `busybox make`; it uses `cl.exe`/`link.exe` and produces `plugins/vd/plugin.dll` without Rust. `busybox make test-vd` checks exports, ID/name reads, and notification registration on a live desktop. Optional checks in the same prompt: `set VDA_TEST_MOVE=1 && busybox make test-vd` moves and pins/unpins a temporary test window; `set VDA_TEST_MUTATE=1 && busybox make test-vd` creates, names, and removes a temporary desktop; `set VDA_TEST_SWITCH=1 && busybox make test-vd` switches to the already-current desktop; `set VDA_TEST_NOTIFY=1 && busybox make test-vd` briefly switches to another desktop and back, checking the posted event. Move, pin-window, temporary-desktop, and notification-delivery checks passed locally on Windows 11 25H2 build 26200.9711. App pinning, cross-desktop window movement/focus, and Explorer-restart recovery have **not** been verified. The mutation test attempts removal even after a failed assertion; check for a leftover `dwhkd-port-smoke` desktop if it fails.
These Explorer COM interfaces are **undocumented and version-sensitive**. Layouts follow upstream's Windows 11 24H2 build 26100.2605+ implementation and may break after Windows updates. The public `IVirtualDesktopManager` only provides window queries/movement; the other APIs are not Rust-only, but are not stable public Windows APIs either.