Click here to Skip to main content
15,896,154 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I can get the record of USB plug in my computer form registration editor of my Windows Operation System,but how I get a USB device pluging in my computer everytime? For example, today I plug a USB device into my computer, I'm sure the cmputer record it.I do the same operation tomorrow.How I get the two Records?

What I have tried:

I've looked up a lot of information,but I cannot do it.
Posted
Updated 14-Dec-16 21:08pm

1 solution

See Registering for Device Notification (Windows)[^].

There are also articles here at CP like Detecting Hardware Insertion and/or Removal[^].

However, using this method requires that the application or service is running when the event occurs.

[EDIT]
If you are interested in older data you might query the Windows event logs. A quick search found this: Digital Forensics Stream: The Windows 7 Event Log and USB Device Tracking[^].
[/EDIT]
 
Share this answer
 
v2
Comments
Member 12564663 15-Dec-16 5:15am    
Thank you very much. I know can use a application to capture messages of WM_DEVICECHANG,but I could not do it like that.I need to use a application collecting the all records of USB plug in equipment.It runs for a period of time.Do it as you said, I could not get the historical records of USB plug and unplug.And I could not let a application run all the time. Anyway,thank you very much.
Jochen Arndt 15-Dec-16 5:31am    
That was not clear from your question.

But you can add such an application to the auto start, so that it can log the events. Such an application would generate only a small system load. It may be also implemented as service.

When looking for historical data you may also query the Windows event logs. I will update my solution to mention that.
Member 12564663 15-Dec-16 6:21am    
I have read it, but it could not help me.I know reading system disk,and analyzing a file can do it.But I donn't know the name of the file.
Jochen Arndt 15-Dec-16 6:41am    
Search for something like "c++ query windows event log":
https://msdn.microsoft.com/de-de/library/windows/desktop/aa385780(v=vs.85).aspx
https://msdn.microsoft.com/en-us/library/windows/desktop/aa385650(v=vs.85).aspx

I added the link to my answer because it contains information about the log entries that you are interested in.
Member 12564663 15-Dec-16 6:50am    
Thank you very much.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900