What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Plug-Ins » [VB6] Closing MSN messenger

Pages: (3): « First [ 1 ] 2 3 » Last »
3 votes - 2.67 average   [VB6] Closing MSN messenger
Author: Message:
J-Thread
Full Member
***

Avatar

Posts: 467
Reputation: 8
– / Male / –
Joined: Jul 2004
O.P. [VB6] Closing MSN messenger
I wrote a plugin in VB6, and now i'm trying to write a setup for it. It does work well, but there is one problem. Because the system message "MessengerPlus_PluginChange" doesn't seem to work for VB plugins, i decided to totaly close msn messenger + all the chat windows (after the user clicked yes of course). But i can't figure out how to do it... Anyone??

(sorry for my bad english...)

07-02-2004 12:45 PM
Profile E-Mail PM Find Quote Report
Wouter
Full Member
***

Avatar

Posts: 252
Reputation: 3
38 / Male / –
Joined: Jul 2003
Status: Away
RE: [VB6] Closing MSN messenger
http://www.msnfanatic.com/index.php?module=announ...23002b7e59fedc8648
[Image: 1497.jpg]      [Image: qbase.jpg]
07-02-2004 12:59 PM
Profile E-Mail PM Web Find Quote Report
Dempsey
Scripting Contest Winner
*****

Avatar
http://AdamDempsey.net

Posts: 2395
Reputation: 53
37 / Male / Flag
Joined: Jul 2003
RE: [VB6] Closing MSN messenger
MessengerPlus_PluginChange works fine for me from VB
SoundPacks   -   Scripts   -   Skins

that's not a bug, thats an unexpected feature
07-02-2004 01:11 PM
Profile E-Mail PM Web Find Quote Report
Choli
Elite Member
*****

Avatar
Choli

Posts: 4714
Reputation: 42
42 / Male / Flag
Joined: Jan 2003
RE: [VB6] Closing MSN messenger
The MessengerPlus_PluginChange works, just be sure you "exetuce" it before you try to overwritte any DLL in use. (both VB and C ones).
Messenger Plus! en espaņol:
<< http://www.msgpluslive.es/ >>
<< http://foro.msgpluslive.es/ >>
:plus4:
07-02-2004 01:32 PM
Profile PM Find Quote Report
J-Thread
Full Member
***

Avatar

Posts: 467
Reputation: 8
– / Male / –
Joined: Jul 2004
O.P. RE: [VB6] Closing MSN messenger
Well i'll try to use MessengerPlus_PluginChange then another time...but i'm almost sure it didn't work for me...

@Wouter: Server not found...
07-02-2004 01:44 PM
Profile E-Mail PM Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15519
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: [VB6] Closing MSN messenger
quote:
@Wouter: Server not found...
MSN Fanatic server is up an running atm

This post was edited on 07-02-2004 at 01:56 PM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
07-02-2004 01:56 PM
Profile PM Find Quote Report
J-Thread
Full Member
***

Avatar

Posts: 467
Reputation: 8
– / Male / –
Joined: Jul 2004
O.P. RE: RE: [VB6] Closing MSN messenger
quote:
Originally posted by CookieRevised
quote:
@Wouter: Server not found...
MSN Fanatic server is up an running atm

What do you mean?? I don't understand...sorry....
07-02-2004 02:28 PM
Profile E-Mail PM Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15519
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: [VB6] Closing MSN messenger
That the link that Wouter gave does work...
.-= A 'frrrrrrrituurrr' for Wacky =-.
07-02-2004 02:31 PM
Profile PM Find Quote Report
J-Thread
Full Member
***

Avatar

Posts: 467
Reputation: 8
– / Male / –
Joined: Jul 2004
O.P. RE: [VB6] Closing MSN messenger
Well not with my provider... I think they've done a DNS change or something... Whatever.
But I can't visit that site, so would you be so kind as to copy the text to this forum?
07-02-2004 02:33 PM
Profile E-Mail PM Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15519
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: [VB6] Closing MSN messenger
Shutting Down MSN Messenger
Posted by daniel on 2003-09-16 05:57:20

At some point in most MSN Messenger applications, you may want to shut down Messenger, or restart it. This could be to apply a patch, or to make Messenger run its shut down routine, like updating the list cache, or removing the systray icon. MSN Messenger has a cross application window message method to make it exit, this is commonly used by its installer. When you install an update the current version is closed so it can overwrite the files.

An obvious method of shutting Messenger down would be to just use TerminateProcess, this method is very forceful and Messenger won't perform its shutdown routine. Before you perform this kind of termination, its best to try the cross application windows message method. This involves sending a custom window message to the Messenger system window "MSNHiddenWindowClass", which is just an always open window for things like receiving events for the systray icon.

You may have before seen a message pop up telling you that you need to close applications that are using MSN Messenger, like Hotmail in Internet Explorer, Outlook Express. The window message method cannot ignore this, therefore you WILL need to forcefully terminate Messenger. You should kill all instances of the Messenger typelib to prevent the message beforehand, otherwise you can get the user to close those applications.

First, lets look at the window message method. You need to register the message "TryMsnMsgrShutdown", and send it to the window with the class name "MSNHiddenWindowClass".
code:
Private Sub GracefullShutdown(bShowCloseMsg As Boolean)
Dim hWnd As Long, lMsg As Long

    hWnd = FindWindow("MSNHiddenWindowClass", vbNullString)
    lMsg = RegisterWindowMessage("TryMsnMsgrShutdown")
    Call SendMessage(hWnd, lMsg, CLng(bShowCloseMsg) + 1, 0)

End Sub
First it gets the handle to the hidden window, then it gets the ID for the custom window message, and last of all it sends the message to the hidden window. If wParam is zero then, if applicable, the message saying to close all applications using Messenger will be shown, if wParam is one then the message will not be shown. Unfortunatly, I dont see a way of it letting us know if the shutdown was successfull, so you then should forcefully shut it down. Its best to wait a second or two to let it do what it needs to do - if it shutdown successfully.

Here is how to forcefully shut it down, by terminating the Messenger process.
code:
Private Sub ForcefullShutdown()
Dim hWnd As Long, lProcessID As Long, lProcess As Long

    hWnd = FindWindow("MSNHiddenWindowClass", vbNullString)
    Call GetWindowThreadProcessId(hWnd, lProcessID)
    lProcess = OpenProcess(0, False, lProcessID)
    Call TerminateProcess(lProcess, 0)
    Call CloseHandle(lProcess)

End Sub
Again, it finds the hidden window, because it is always open. It then puts the process ID for that window into a var, creates a process handle to use to be terminated, terminates the process. And closes the process handle, freeing up resources.

Here are the API declarations for those used.
code:
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

Declare Function RegisterWindowMessage Lib "user32" Alias "RegisterWindowMessageA" (ByVal lpString As String) As Long

Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long

Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hWnd As Long, lpdwProcessId As Long) As Long

Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long

Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long

Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
.-= A 'frrrrrrrituurrr' for Wacky =-.
07-02-2004 02:42 PM
Profile PM Find Quote Report
Pages: (3): « First [ 1 ] 2 3 » Last »
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On