473,785 Members | 2,789 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to extract filename information from running processes ?

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 ?

For example : If I have opened xyz.docx in MS Word 2007 then I want to
find out the name of the file ("xyz.docx") and its complete path
through some mean which could be either :

1. Reading or extracting information from the Word 2007 process
handle.
2. Through another non- handle based general method.

Kindly help !

Regards,

Aditya

May 23 '07 #1
3 2658
Hello adimangla,

Everything you need to do is enumerate all processes and find the process
to which your handle belongs to.
..NET doesn't provide the AFI for this, you need to dive deeper, more deep
then WINAPI - to the nt.dll level, where you can find undocumented ZwQueryObject() .

Using this methods is not a simple task, because it returns name and info
about handle belonging to the YOUR process.
So, you need to perform additional task - use DuplicateHandle () to bring
external handle to your process.

I recomend you to study this sample http://www.codeguru.com/Cpp/W-P/syst...icle.php/c2827

which provide all functional u requre.

---
WBR, Michael Nemtsev [.NET/C# MVP].
My blog: http://spaces.live.com/laflour
Team blog: http://devkids.blogspot.com/

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo

aHi :-)
aI am creating a software that will save the present state of all the
aapplications running on the desktop (WinXP).
aCan anyone point out the method to extract the filenames from the
ahandles (or otherwise) of the files that are being accessed by
aprocesses and programs ?
a>
aFor example : If I have opened xyz.docx in MS Word 2007 then I want
ato find out the name of the file ("xyz.docx") and its complete path
athrough some mean which could be either :
a>
a1. Reading or extracting information from the Word 2007 process
ahandle.
a2. Through another non- handle based general method.
aKindly help !
a>
aRegards,
a>
aAditya
a>

May 23 '07 #2
Hi,

"adimangla" <ad******@gmail .comwrote in message
news:11******** *************@o 5g2000hsb.googl egroups.com...
Hi :-)
I am creating a software that will save the present state of all the
applications running on the desktop (WinXP).
So in other words, you are trying to create a "hibernatio n" features

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 ?
Can be done, it's a PITA to make it, be ready to P/invoke as crazy as well
as creating some unmanaged code (and not a trivial one)
For example : If I have opened xyz.docx in MS Word 2007 then I want to
find out the name of the file ("xyz.docx") and its complete path
through some mean which could be either :

1. Reading or extracting information from the Word 2007 process
handle.
2. Through another non- handle based general method.
What you want to do is not easyly done, as a matter of fact is a SUPER
complex process that maybe only the OS can do succesfuly.

I suggest you to look another project.
May 23 '07 #3
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
May 23 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2010
by: Joe | last post by:
I'm trying to get the location of the image uisng start = s.find('<a href="somefile') + len('<a href="somefile') stop = s.find('">Save File</a></B>', start) fileName = s and then construct the url with the filename to download the image which works fine as cause every image has the Save File link and I can count number of images easy the problem is when there is more than image I try using while loop downlaod files, wirks fine for the...
3
4269
by: K.S.Liang | last post by:
Hi all, 1> If there are more than one dynamic linking libraries in the file system, how do I know which one is loaded into system? Any C library or system call can tell me which *.so or *.sl is active? Can the setting of LD_LIBRARY_PATH guanrantee that the correct one is executed? 2> In MS-WINDOWS, once a DLL is loaded by one allication, this DLL will be used by the subsequent appication. Does UNIX have the same
2
7439
by: Kumar | last post by:
Hi Folks, I would like to develop one custom application using asp.net,C#,SQL server for tracking all our company servers. Most of the functionality is similar to HP Systems Insight Manager (http://h18013.www1.hp.com/products/servers/management/hpsim/) I would like to store as much information as we can about server.
4
2444
by: Dave | last post by:
I am writing a C# app in which I need to enumerate the processes running on the PC. I have succesfully done this as follows (assuming the app is running on NT4, XP, 2000 or 2003): ManagementScope ms = new System.Management.ManagementScope("\\\\localhost\\root\\cimv2"); ObjectQuery oq = new System.Management.ObjectQuery("SELECT * FROM Win32_Process"); ManagementObjectSearcher query = new ManagementObjectSearcher(ms,oq);...
9
3502
by: chrisspencer02 | last post by:
I am looking for a method to extract the links embedded within the Javascript in a web page: an ActiveX component, or example code in C++/Pascal/etc. I am looking for a general solution, not one tailored to a particular page/script. Hopefully, the problem can be solved without recreating a complete Javascript interpreter. Any ideas?
8
2841
by: Fabian Braennstroem | last post by:
Hi, I would like to remove certain lines from a log files. I had some sed/awk scripts for this, but now, I want to use python with its re module for this task. Actually, I have two different log files. The first file looks like: ...
0
938
by: kissii | last post by:
Hi , i am new to VB. I want to know what are the processes running in system. what i am thinking is if i can get how to access system tray information, i can get all the processes/services running in system. Can you please guide me how to get system tray information. Thanks in advance Kishore.
2
3101
by: Fabian Braennstroem | last post by:
Hi, I would like to delete a region on a log file which has this kind of structure: #------flutest------------------------------------------------------------ 498 1.0086e-03 2.4608e-04 9.8589e-05 1.4908e-04 8.3956e-04 3.8560e-03 4.8384e-02 11:40:01 499 499 1.0086e-03 2.4608e-04 9.8589e-05 1.4908e-04
5
5765
by: Steve | last post by:
Hi all Does anybody please know a way to extract an Image from a pdf file and save it as a TIFF? I have used a scanner to scan documents which are then placed on a server, but I need to extract the image of the document (just the first page if there are multiple pages) and save it as a TIFF so I can then use the Tesseract OCR to get the text in the image.
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9481
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10336
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10155
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9953
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7502
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6741
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5383
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3655
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.