Click here to Skip to main content
15,893,487 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello

I am having a problem when running my installer, i need to close nicely my app that is a notify icon app i use the Process class to do it but the MainWindowHandle is returning 0 and even the CloseMainWindow method doesn't work :(

but i tried using FindWindow with the class name and the window text showed by spy++ and send a WM_CLOSE message and it works.

But the class_name in my app is not fixed, is there any way i can fixed or an workaround somebody?

Thanks
Posted
Updated 28-Sep-11 14:35pm
v2
Comments
Sergey Alexandrovich Kryukov 28-Sep-11 23:11pm    
Not clear. Please, explain it all systematically. Do you want to close the same application starting another one? Which process do you want to close application (same as application or not) and which one -- to start another one. Explain the purpose of all this activity, maybe you don't really need it.
--SA
Dirk C De Winnaar 29-Sep-11 11:10am    
Use a timer to close your app in say 1.5 sec after starting the new one.

1 solution

I'm assuming you want to close your application from your installer.
Right on top of my head I see two opntions
0) use Process.GetProcessesByName[^] to get the process of your application, and then send WM_CLOSE to the window with the handle Process.MainWindowHandle[^]
1) Use IPC, though this seems like overkill.
 
Share this answer
 

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