Application A (for example: AutoCAD, Word,…) when runs, it’ll call a DLL X at runtime to perform tasks → open form Login
Application B (for example: Photoshop, Excel…) when runs, it’ll call a DLL Y at runtime to perform tasks → I would like to close the above login form can do this?
Is that possible?
3
Answers
well if its just about closing the running proccess the easiest way would probably be like something like
for opening you could probably cycle the proccesses for the needed names. its not very efficent tough but it would get the job done if its just opening and closing you´re after
You could keep checking for new processes with a (just an example) windowless console application. I have an example:
Make a new project with a console application and the login form
Make the Console application a windows application like this:
Press properties
Select Windows application
Make a timer in the console application that checks for processes:
The logic for closing a Form when an application closes can be put inside this timer too, use it the same way.
To open a form from a console window however you need to add references to the console application:
If you want process names:
Just use a form and add this:
This will show you the names of all processes currently running.
Here is a little sample that shows how to close a Window in another process. Create a new Windows Forms project, Add two Forms in it and add two buttons on the first one and put that code in Form1 :
Compile and then run two instances of the application. On the first one click on Button1 to show Form2. On the second instance click on Button2 to close Form2 from the first instance.