Click here to Skip to main content
15,887,027 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
someone please tell me the answer ?
Posted
Updated 27-Aug-14 2:21am
v4
Comments
Richard MacCutchan 27-Aug-14 8:22am    
Which is it, C++ or C#? In either case a bit of Googling or a search of MSDN would probably help you.
keyur chauhan 27-Aug-14 8:32am    
@Richard MacCutchan , its c++ , i googled a lot ,i am able to detect windows created by applications such as internet explorer , google chrome , visual studio using CBT hook , but cant detect windows created by notepad or directory windows
Sergey Alexandrovich Kryukov 27-Aug-14 12:10pm    
There is no such concept as "open directory"; only the file can be open.
—SA

None. No such "hook" exists.

Opening a file in an application is not some mystical thing. It happens all the time, system wide, not just when you double-click something.
 
Share this answer
 
v2
Comments
keyur chauhan 27-Aug-14 8:36am    
is there any other way ??
Sergey Alexandrovich Kryukov 27-Aug-14 12:11pm    
Why?
—SA
Dave Kreskowiak 27-Aug-14 15:00pm    
What are you doing that you think you need to "hook" a file being opened??
keyur chauhan 28-Aug-14 1:28am    
@Dave Kreskowiak , i want to protect the file using the password , so that only those who know the password can open it.
Dave Kreskowiak 28-Aug-14 8:37am    
No, you're not. This is FAR more complicated to do than you realize.

First, what would happen if backup software or a virus scanner tried to open the file and nobody was logged in to type in the password?

Second, this needs to be written in C, not C# or VB.NET. NTFS extensions and Windows drivers are best written in C, not C# or VB.NET.

Third, how are you going to set passwords for each file? Where are you going to store them? How do you handle setting passwords on multiple files at one time? How are you going to handle recovering the files from lost passwords? ...? ...? ...?

This is not some simple little tool some newbie can whip up and expect to work. There's a reason you don't see this little application all over the web. It's very difficult to implement and offers no benefits at all beyond what NTFS security already offers.
In your question you speak about "hooking" on opening files, but afterwards you speak about detecting windows. These are different things..
Well, you might not be able to detect all events, if they are transient, but might be one approach periodically walking trough open file handles, see for example: Listing Used Files[^]
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 27-Aug-14 12:14pm    
This interesting article, could be very useful, my 5. However, I'm not sure if it can help OP, who may not understand what he needs; mentioning non-existing "concept" of "opening a directory" clearly tells a tale.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900