Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 239
  • Last Modified:

how to know how iam running the exe....

hi all,
i have two exe files(exe1 and exe2)...i can run exe2 from exe1... and also run exe2 seperately......i want to know whether my exe2 is being run independently or from exe1....

please help me to solve this problem

regards...
yateesh
0
yateesh
Asked:
yateesh
  • 2
  • 2
1 Solution
 
AndyAinscowCommented:
The two processe are separate so there is no native way to determine what you want.
However if you launch exe2 from exe1 you could pass a command line parameter that would allow you to determine that exe2 was launched from exe1 (that command line param would not be available when you launched it independantly, eg. -z12345)
0
 
yateeshAuthor Commented:
can u send me an example showing how to do it.....
0
 
AndyAinscowCommented:
ShellExecute(NULL, "open", "C:\\myapp1.exe", "-z12345", "c:\\", SW_SHOWNORMAL);

end in exe2 (InitInstance)

CString str2Param;
if ( __argc >= 2 )
   str2Param = __targv[1];    str2Param should now be "-z12345"
0
 
zaerazerCommented:
Hi,

Use a CMutex : Create it in exe1
in exe2 : if you try to create the same mutex, os will tell you that mutex already exists and so that exe1 is running ...
0
 
yateeshAuthor Commented:
hi Andy,
if i hav invoked exe2 from exe1.....
i hav to kill exe2 when exe1 exists...
how can i do that


regards
yateesh
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now