Click here to Skip to main content
15,883,883 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
I have made an application that consists of 2 EXEs. The MainEXE sends data to the SecondaryEXE and reads its output and Wait_it_ForExit.

The question is: Can I prevent the SecondaryEXE from opening if the user DoubleClicked it.

i.e. The SecondaryEXE should ONLY be Run from within the MainEXE.

Any Ideas.. Or Is such thing even possible??
Thanks in Advance.
Posted

No, you can not "prevent double click". The click is done by the user; this is beyond your control.
You can easily do one simple thing: change extension of the executable file. You run the application using System.Diagnostics.Process.Start. For this call, extension does not matter at all, but the Shell won't recognize the file as executable on double click.

But why?
There is not point of running to processes. Make it all in one process. Make you second executable a library and run some method you want in your calling process. You can do in main thread or create a separate thread for it. You can even run it in a separate Application Domain. It all depends on you purpose. Anyway, there is practically nothing in creating of a separate thread which you can not achieve in just one process.

For more advanced uses, read this: Create WPF Application that uses Reloadable Plugins...[^].

—SA
 
Share this answer
 
v3
Comments
Henry Minute 26-Mar-11 19:53pm    
Reply from OP:

Moved here from answer - since deleted.
Thanks for response.
A pretty good idea you provided.
What I meant is preventing the SecondaryEXE from running if the user DoubleClicked it, not preventing the user from DoubleClicking it.
I am working on a project that is supposed to be run using parallel computing
Each Module is supposed to do a particular job and could be anywhere.
Any way. Thanks So Much.
Sergey Alexandrovich Kryukov 26-Mar-11 21:48pm    
@AliNajjar: I understand. The notion of module along suggests if can be a library (DLL), each library being a separate assembly in the same process, not a separate process like you have with EXEs; you also have more freedom. Only if you need to load assembly dynamically (because of different set of libraries for different configuration of the same application), you need to load the assemblies during run time, in this case, follow my reference above.

Are you going to formally accept my Answer?
--SA
Sandeep Mewara 27-Mar-11 2:43am    
My 5!
Sergey Alexandrovich Kryukov 27-Mar-11 13:42pm    
Thank you, Sandeep.
--SA
Аslam Iqbal 27-Mar-11 7:12am    
Good solution for OP. my 5
-SA Advised you to perfect solution. Try your second exe to dll library.
If you still want to keep your 2nd.exe you can pass an argument from 1st.exe to 2nd.exe, and check that argument from 2nd.exe. If it match that specific arg value then continue farther processing else terminate it.When user double click on 2nd.exe it will not pass any argument or if passed then it is matched to your passed argument.
To know about command line argument see this article:
C#/.NET Command Line Arguments Parser[^]
or
Command Line Arguments[^]
 
Share this answer
 
v2
Comments
Sergey Alexandrovich Kryukov 27-Mar-11 14:16pm    
This is less reliable and needs more effort, but acceptable, I would say, 4.
Anyway, using EXE is wrong where a library can work. I mentioned it in my answer.
--SA
Аslam Iqbal 27-Mar-11 14:23pm    
It was an extension of your answer. Even I Never try this thing. I always do what you told. But if the OP can't do/don't want to do what you told. By the way thanks.
Sergey Alexandrovich Kryukov 27-Mar-11 14:48pm    
I think you're right. We probably already listed all what can be done, now it's OP's turn. :-)
--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