This question already has answers here:
How do I get the list of open file handles by process in C#?
(7 answers)
Closed 1 year ago.
I need a way for getting all of the file handles of a given process.
for example, given a the winword.exe process handle, i would like to get the list of the file handles of that process (doc files etc).
i'm using the Win32 api via C#/pInvoke.
Thanks!
An easy solution would be to use handle.exe and read its output. Another solution is to use P/Invoke with NtQuerySystemInformation function. This and this forum post on SysInternals has more details as well as this article on CodeProject. Doing it in managed code could be very difficult as you will need to write a driver to read the kernel address space.
I would suggest you to expose the needed functionality in a Win32 function that you could call from managed code.
In complement to Darin answer, see also this codeguru page and this sysinternal forum post
Related
This question already has an answer here:
It is possible to read .Rdata file format from C or Fortran?
(1 answer)
Closed 6 years ago.
I have requirement to read data from ".RData" files and process them in C# application. I could not find any API which I can use in C#, I believe there is an API for F# which I don't use as of now because of learning curve in F#.
Could anybody please suggest code or API to read ".Rdata" files?
There's R.NET which would allow you to execute the load function, then get the saved variables from the environment, maybe? My guess is you'll need to run something like
engine.Evaluate("load('/my/data/dir/mydata.RData')");
var data = engine.GetSymbol("myvariablename");
This question already has answers here:
Notification when a file changes?
(3 answers)
Closed 8 years ago.
I have inherited application that, among many other things, has to watch if user writes/deletes text file into specific folder.
Currently, the application uses timer and polls after 5 seconds. I find this ineffective, and wish to improve this part of code.
My question is about existence of the .NET function that monitors changes in directory. Is there such function I can use to detect when a file is written/deleted in a specified folder?
Thank you.
Yes, you have the FileSystemWatcher class. It does exactly what you're looking for
Yes there is. I would suggest you take a look at the FileSystemWatcher class:
http://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher%28v=vs.110%29.aspx
It's quite easy to set up, and it monitors for Win32 events, so is relatively inexpensive to use.
This question already has an answer here:
How to detect a process start & end using c# in windows?
(1 answer)
Closed 8 years ago.
I am looking for a way to record when certain programs have been executed.
For instance, if Microsoft Word has been started I would like to write out a time and date stamp along with the program name.
The output I get. I may change it to an Excel spreadsheet. Just need a little guidance on where to look to capture user run programs.
It looks like you want to use the ManagementEventWatcher
example
msdn
As for creating an excel spreadsheet from data, you can easily find code for that.
like this
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Is there a way to overlay an application over a full-screened program?
Is it possible in C# to inject a text to process (like fraps for example), but without using any .dll injections?
Thanks in advance for responses.
#update
"A text" means some fast refreshing labels or something, which will show informations e.g.:
Name:Test
Pos: x=123,y=456,z=0
Level: Unknown
Something.....
You can use automation to send keyboard actions and suchlike to another program. Otherwise if there is no exposed API then things look bleak. See this question for an overview on the methods you use to send keystrokes.
EDIT: What you're asking for is not injection, it's an overlay. What you're looking to do is take control of the display buffer so that your overlay always has a higher z-index than whatever is being rendered. Take a look at this answer
This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Looking for C# code for detecting removable drive (usb flash)
How could the System.IO.FileSystemWatcher class be used to detect drives (e.g. F:) being connected/disconnected under windows? If this is not possible, what other event driven ways are possible (other than polling DriveInfo.GetDrives())?
Thanks in advance.
Take a look at this:
http://www.codeproject.com/KB/system/DriveDetector.aspx
I wrote a powershell module that uses a System.Management.ManagementEventWatcher and the WMI class Win32_VolumeChangedEvent to surface new events that you may register for within powershell covering device removal, addition etc. You should be able to figure out the relevant plumbing from this blog post of mine:
http://www.nivot.org/nivot2/post/2008/08/16/AutoMountunmountNewPSDrivesForRemovableDrivesAndNetworkSharesInPowerShellV2.aspx
You should be able to wire up an event for new drives in less than ten lines of C# using the methods I use in the above script.
Hope this helps.