by Tom Pydeski (16 Submissions)
Category: Windows System Services
Difficulty: Intermediate
Date Added: Wed 3rd February 2021
Rating:
(9 Votes)

'module for subclassing the DeviceChange Windows Message
'Windows sends all top-level windows a set of default WM_DEVICECHANGE messages when
'new devices or media (such as a CD or DVD) are added and become available, and when
'existing devices or media are removed.
This program should detect the following:
-CD or DVD inserted into drive
-Floppy inserted
-USB thumbdrive or external hard drive added
-USB serial port added
-probably a lot of other hardware changes, but
I could not test a lot of others
Modified to add Device Notification information about new hardware.
Assumes
Run the code and change hardware.
Code Returns
Displays data for the proper structure for new devices
Side Effects
It subclasses, so DON'T Quit the IDE without closing the program first or VB will CRASH!
API DeclarationsDeclare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (pDst As Any, pSrc As Any, ByVal ByteLen As Long)
Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long