I am looking solution for display custom message to the user whenever any external device (USB,Bluetooth,HDMI,etc) connected to the pc using the csharp application I tried with WMIQuery but I could not reach ,Is any solution available?
Loading
I am looking solution for display custom message to the user whenever any external device (USB,Bluetooth,HDMI,etc) connected to the pc using the csharp application I tried with WMIQuery but I could not reach ,Is any solution available?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Jayraj ChhayaPosted Jan 12, 2024, 6:44 AM
To display a custom message when an external device is connected to a PC using a C# application, you can utilize the
ManagementEventWatcherclass from theSystem.Managementnamespace. This class allows you to monitor WMI events and execute code when a specific event occurs.Here's an example of how you can achieve this:
In this example, we create a
ManagementEventWatcherobject with a WMI query that filters for device connection events (EventType = 2). We then set an event handler (DeviceConnected) to execute code when a device connection event occurs. Inside the event handler, you can customize the code to display your desired custom message to the user.Remember to add a reference to the
System.Managementassembly in your C# project.This solution allows you to monitor and respond to external device connection events in real-time within your C# application.
Naimish MakwanaPosted Jan 12, 2024, 4:37 AM
Try below code:
Thanks
Sachin SinghPosted Jan 11, 2024, 3:37 PM
check if this helps
Janani VeeramanikandanPosted Jan 11, 2024, 3:26 PM
How can get device name which was connected
Sachin SinghPosted Jan 11, 2024, 3:21 PM
Test this