I am writing an “add-on” for Windows Picture viewer that will need to send commands to it (like “Show next/previous image”) and obtain file path to currently selected image. I managed to implement sending commands via SendMessage, but I don’t know how to request info from a process. Is this possible?
So far I can only extract filename from window title, but this restricts usage to just one folder, I need the full path.
[EDIT] I did some search and found, that there’s (undocumented?) possibility to find list of all handles used by process, using function NTQuerySystemInformation (As seen here Delphi – get what files are opened by an application).
The problem is, however, that the example provided there doesn’t show file handles for me at all (only non-harddrive device handles), and while I found working example here http://www.codeguru.com/Cpp/W-P/system/processesmodules/article.php/c2827/, seems like Picture Viewer doesn’t hold any handle to previewed file when launched from explorer.
You can get the Process “Current Directory” (as shown in Process Explorer).
Take a look at Two ways to get the command line of another process using Delphi by RRUZ.
Based on that article, we could get the
CurrentDirectoryfound in theRTL_USER_PROCESS_PARAMETERS(offset 36) structure:Here is how to obtain
CurrentDirectory: