Anony-mouse321

I am working on an application which will provide a "virtual" file system which is visible in Windows Explorer as any other folder. This folder can contain items which are currently available and one that aren't. I am looking for suggestions on how I can prevent the files which aren't currently available being opened (as the opening application will display an error as the file has no content).

I have built an IShellExecuteHook which prevents the opening of most files with the exception of images opened via shimgvw.dll (Window Picture and Fax Viewer), videos opened by Media Player and anything using DDE to open. Is there a way I could display a friendly message to the user if they attempt to open a file which is not available and prevent the associated application from opening




Re: Visual C# General Suggestions to prevent a file being opened

Peter Ritchie

You're implementing IShellExecuteHook in a C# application You may want to check out http://blogs.msdn.com/junfeng/archive/2005/11/18/494572.aspx

There's no way to prevent a file from being opened without implementing some sort of system hook, which can't be done in a managed language.






Re: Visual C# General Suggestions to prevent a file being opened

Anony-mouse321

Thanks for the reply.

The prototype IShellExecuteHook I wrote was in C# but I am quite comfortable writing whatever I need in C++ if necessary, I just need to know which direction I should be heading.

You mention a system hook, could you elaborate on that a bit, I having been searching not found any information relating to what I am trying to achieve.

Thanks.




Re: Visual C# General Suggestions to prevent a file being opened

Peter Ritchie

There's various ways of hooking Win32 functions, for example http://www.codeproject.com/dll/DLL_Injection_tutorial.asp

. All of which require a DLL that implements DllMain or specific entry points--neither of which can be done in a managed application.