misc_bb 7 Posted April 28, 2022 I'm able to get the PID of a processname (ex: winword.exe) but interested of getting the PID of winword.exe based on a specific filename, is this possible? I was able to look capture the PID from winword but if there are multiple instance I can't kill all instance but only a specific one. I'm not so familiar with Winapi handling, based on this post: Delphi Get the handle of a EXE he is trying to change his approach from 'Window name' to an Exe name. But parameter @processid needs to be specified. How can I get the processid in this case based on filename or window name? Share this post Link to post
Remy Lebeau 1393 Posted April 28, 2022 There is no easy way to identify which file(s) a process has open (there are hard ways, though). But you are assuming that WinWord actually keeps the file open, and is not simply reading the whole file into memory and then closing the file, operating on the memory until you save again. You are most likely just going to have to search through window titles to know which WinWord window is operating on which file. Share this post Link to post
Fr0sT.Brutal 900 Posted April 28, 2022 2 hours ago, Remy Lebeau said: But you are assuming that WinWord actually keeps the file open, and is not simply reading the whole file into memory and then closing the file, operating on the memory until you save again. Actually that's what Word does. It occupies the opened file for the whole edit cycle blocking it from access Share this post Link to post
misc_bb 7 Posted April 28, 2022 Thank you for the idea on this topic. I don't want to go the hard way I can probably do this one at a time. I'll just terminate winword after every documents' final save until the next document opens. Share this post Link to post
David Heffernan 2345 Posted April 28, 2022 Does Word use a separate process for each open document? Share this post Link to post
David Heffernan 2345 Posted April 28, 2022 Does Word use a separate process for each open document? Share this post Link to post
Lajos Juhász 293 Posted April 28, 2022 1 hour ago, David Heffernan said: Does Word use a separate process for each open document? No. With two opened documents task manager show a single PID. Share this post Link to post
Stano 143 Posted April 28, 2022 Can anyone else open Word there? Because if so, you have a problem. Share this post Link to post
David Heffernan 2345 Posted April 28, 2022 9 hours ago, Lajos Juhász said: No. With two opened documents task manager show a single PID. Which means the original idea was doomed. Share this post Link to post