First, use WinApi to check which window has focus. Is this an explorer window? Make sure that this is the type of window you are looking for by checking its attributes. And if so, check when the user clicks the left mouse button using GetAsyncKeystate, which notices the input all .
When you get the left mouse button, select the time to check if the user clicked on the file view. Go through the elements of the GUI window until you find someone who has keyboard focus. Get the container / frame ID for the file list using Spy ++. Now check if the focused / selected element is inside this frame and, most importantly , if it is a list item . Get the name / caption attribute of the element, and you're done!
I hope you understand that because of the length of this process, I cannot and will not give you the complete code to do this ... Tell me if there is something that you do not understand.
David source share