JustinWillis
asked on
SendMessage Close MSN Messenger
Hello, I am trying to use the following to close MSN Messenger (I want to shut it down altogether if possible or at least stop it working while my app is running).
SendMessage(FindWindow('MS NMSBLClass ','MSN Messenger'),WM_CLOSE,0,0);
Only problem is of course is that it uses OnClose to prevent the close and minimizes to the tray instead.
I have experimented with Destroying it but this is messy and causes errors.
Is there a nice clean way of preventing MSN Messenger from working? or shut it down altogether?
Thanks for any help.
Justin Willis.
SendMessage(FindWindow('MS
Only problem is of course is that it uses OnClose to prevent the close and minimizes to the tray instead.
I have experimented with Destroying it but this is messy and causes errors.
Is there a nice clean way of preventing MSN Messenger from working? or shut it down altogether?
Thanks for any help.
Justin Willis.
ASKER
Yes I have also tried that, doesn't do anything at all, Messenger is resisting, I think I need a way to trigger the Exit option within messenger, or can I send it an application.terminate sort of message in an ideal world?
ASKER
Points increased.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
darn beat me to it
well done din345
well done din345
ASKER
Very cool, thanks a lot din345, I was trying this with version 6.2 and changed the classname to MSNMSBLGeneric which seemed to work a treat but will need to close other versions as well so will check for 7 and earlier, sure it will work fine.
Out of interest what is this actually doing? is this similar to remote application.terminate?
I was trying out wm_destroy before which seemed to take a baseball bat to the apps legs, this also caused other progs to become unstable though (Internet Explorer was a biggy).
Thanks again,
Justin Willis.
Out of interest what is this actually doing? is this similar to remote application.terminate?
I was trying out wm_destroy before which seemed to take a baseball bat to the apps legs, this also caused other progs to become unstable though (Internet Explorer was a biggy).
Thanks again,
Justin Willis.
GetWindowThreadProcessId(F indWindow( 'MSBLWindo wClass', nil), @pid); // here it gets the process ID and stores it in pid
ProcessHandle := OpenProcess($0001, FALSE, pid); // OpenProcess() returns a handle of the process
GetExitCodeProcess(Process Handle, ExitCode); // the exitcode is stored in ExitCode and it's used in TerminateProcess()
TerminateProcess(ProcessHa ndle, ExitCode); // termiantes the process
CloseHandle(ProcessHandle) ; // closes the handle
> is this similar to remote application.terminate?
i don't know.
ProcessHandle := OpenProcess($0001, FALSE, pid); // OpenProcess() returns a handle of the process
GetExitCodeProcess(Process
TerminateProcess(ProcessHa
CloseHandle(ProcessHandle)
> is this similar to remote application.terminate?
i don't know.
ASKER
Thanks for clarifying, it makes sense now.
Cheers,
Justin Willis.
Cheers,
Justin Willis.
SendMessage(FindWindow('MS
instead
regards