How to close an file in an running process from another process?

X

xhy_China

How to close an file in an running process from another
process?
For example:
There are two running processes,named procIn and
procFrom. A file
named needCloseFile was opened in procIn. Now I want to
close the
needCloseFile from procFrom by programming,but left
procIn running normally.
What can I do???


Thx for your reply!!
 
B

Bela Istok

What is the motive for that? I guest that would you like to open the file
from procFrom, and the system says it's begin used by other process, no? if
this is the case you can share the file between the 2 processes.

Regards,

Bela Istok
 
X

xhy_China

What is the motive for that? I guest that would you like to open the file
from procFrom, and the system says it's begin used by other process, no? if
this is the case you can share the file between the 2 processes.


No, I only want to know how to close ! !
 
W

Willy Denoyette [MVP]

|
| > What is the motive for that? I guest that would you like to open the
file
| > from procFrom, and the system says it's begin used by other process, no?
if
| > this is the case you can share the file between the 2 processes.
| >
|
|
| No, I only want to know how to close ! !
|

The simple answer is - you can't close a file you don't own, only the
process that has opened the file can close it.

Willy.
 
X

xhy_China

"Willy Denoyette [MVP] дµÀ£º
| > What is the motive for that? I guest that would you like to open the
file
| > from procFrom, and the system says it's begin used by other process, no?
if
| > this is the case you can share the file between the 2 processes.
| >
| No, I only want to know how to close ! !

The simple answer is - you can't close a file you don't own, only the
process that has opened the file can close it.


but what does the software unlocker do after press the unlock button ?
It makes the file in using can be delete or move. how does it realize
this function???
 
W

Willy Denoyette [MVP]

"Willy Denoyette [MVP] дµÀ£º
| > What is the motive for that? I guest that would you like to open the
file
| > from procFrom, and the system says it's begin used by other process,
no?
if
| > this is the case you can share the file between the 2 processes.
| >
| No, I only want to know how to close ! !

The simple answer is - you can't close a file you don't own, only the
process that has opened the file can close it.


but what does the software unlocker do after press the unlock button ?
It makes the file in using can be delete or move. how does it realize
this function???

Well, "Unlockers" are tools that need high privileges (SeDebugPrivilege) to
run and inject DLL's into the external process, they attach a filesystem
driver to delete the file under the other process feet.
Not something you can't (and should) do in managed code.

Willy.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top