Archive: Checking if program is open..


How would i check if the program ( the .exe that my nsi installs ) is open?

Becuase if somone uninstalls while they have the program open, it wont delete the program..


[list][*]FindWindow close|closeinstant|prompt|goto:label windowclass [messageboxtext]
Checks for a window whose class name is 'windowclass'. If the window is found, the action is based on what 'mode' is set to.
- If mode is 'close', this command will attempt to close the window using WM_CLOSE for up to 8 seconds.
- If mode is 'closeinstant', this command will send a WM_CLOSE message to the window and continue.
- If mode is 'prompt', this command will prompt the user with 'messageboxtext' until the window is closed manually.
- If mode is 'goto:label', FindWindow will Goto label.
[*]FindWindowByTitle close|closeinstant|prompt|goto:label windowtitle [messageboxtext]
Acts like FindWindow, only searches for a window based on title instead of class.

An example:

Function un.CloseApp

FindWindowByTitle goto:lbl_found 'Program v1.x'
goto lbl_end

lbl_found:
MessageBox MB_YESNO 'Your program is active at the moment. Do you want to close it?' IDNO lbl_end
FindWindowByTitle close 'Program v1.x'

lbl_end:

FunctionEnd

Declare the function in the un-istall section. And call the function before you're going to remove everything.