Win32 specific: Using SHChangeNotifyRegister to get notifications

on removable media insert / eject events.
From now on we no more poll for removable media on Windows.

Thanks @mjgtp from prusaprinters.org
See the following discussion:
https://forum.prusaprinters.org/forum/prusaslicer/prusaslicer-trying-to-access-my-floppy-disk-a

The final working code sample was taken from Chromium source code,
volume_mount_watcher_win.cc
This commit is contained in:
bubnikv 2020-03-27 08:10:00 +01:00
parent 3fdd643f49
commit 58192ba6c2
4 changed files with 73 additions and 11 deletions

View file

@ -144,6 +144,8 @@ public:
#ifdef _WIN32
void* m_hDeviceNotify { nullptr };
uint32_t m_ulSHChangeNotifyRegister { 0 };
static constexpr int WM_USER_MEDIACHANGED { 0x7FFF }; // WM_USER from 0x0400 to 0x7FFF, picking the last one to not interfere with wxWidgets allocation
#endif // _WIN32
};