On Wed, 23 May 2007 06:18:14 -0700, adimangla <ad******@gmail.comwrote:
Hi :-)
I am creating a software that will save the present state of all the
applications running on the desktop (WinXP).
Can anyone point out the method to extract the filenames from the
handles (or otherwise) of the files that are being accessed by
processes and programs ?
As a very basic example of where this is going to fail:
What are you planning to do about applications that behave like Notepad?
That is, they open a file and read the data, and then just close it again,
working solely from a copy of the data in memory. Without very specific
information about the internal data structures for the application *and*
complete access to that process's virtual address space, it is impossible
to determine where the file came from. And if the application doesn't
save the original file location anywhere (Notepad does, but there's no
requirement that it should), you're out of luck. The information is
simply not there to be retrieved.
And in any application, what do you plan to do when the user hasn't saved
the document yet?
Now, all that said, you certainly can achieve with at least some limited
success what you're trying to do. But your success *will* be limited, and
you definitely cannot literally "save the present state of all the
applications running on the desktop". There is a LOT more to the "present
state" than just the filenames of the files a given application has open
at the moment. Even if you could reliably get all of the filenames of all
the original source data for which there *are* filenames, that doesn't
give you anywhere close to all of the information about the application's
"present state", and that doesn't even consider situations in which the
user hasn't saved the application's documents yet, or applications that
don't even have a document-oriented user-interface.
In any case, whatever it is you plan to do, I'm pretty confident that
managed code isn't going to be the right place to do it. You can't get
access to what you apparently want access to from managed code.
Pete