VBcoders Browse New Submit Contact Sign In

No account? Register free

Forgot password?

Windows Device Message Hook

Tom Pydeski  (16 Submissions)   Windows System Services   Intermediate   Wed 3rd February 2021

'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.

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 Declarations
Declare 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

Rate Windows Device Message Hook (9(9 Vote))

Download Windows Device Message Hook

Windows Device Message Hook Comments

No comments yet — be the first to post one!

Post a Comment

0/1000 characters