[VB6] Closing MSN messenger |
Author: |
Message: |
J-Thread
Full Member
Posts: 467 Reputation: 8
– / / –
Joined: Jul 2004
|
O.P. RE: [VB6] Closing MSN messenger
Tnx!
|
|
07-02-2004 02:45 PM |
|
|
matty
Scripting Guru
Posts: 8336 Reputation: 109
39 / /
Joined: Dec 2002
Status: Away
|
RE: [VB6] Closing MSN messenger
Only one problem, if you have conversation windows open it wont shut down, it will ask if you wish to close them first.
This is the code I used to close all of the IM Windows, do this before doing the graceful and forceful shutdowns on MSN
code: Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Declare Function SendMessageLong& Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long)
Public Const WM_CLOSE = &H10
Public Function closeAll()
Dim imwindowclass As Long
10 imwindowclass = FindWindow("imwindowclass", vbNullString)
If imwindowclass <> 0 Then
Call SendMessageLong(imwindowclass, WM_CLOSE, 0&, 0&)
GoTo 10
Else: Exit Function
End If
End Function
|
|
07-02-2004 03:04 PM |
|
|
J-Thread
Full Member
Posts: 467 Reputation: 8
– / / –
Joined: Jul 2004
|
O.P. RE: RE: [VB6] Closing MSN messenger
quote: Originally posted by Dempsey
MessengerPlus_PluginChange works fine for me from VB
I know how to shutdown messenger now, but i rather like to just reload the plugins... Why doesn't it work for me . Could you please past you code here... To see what i am doing wrong...
|
|
07-02-2004 03:15 PM |
|
|
matty
Scripting Guru
Posts: 8336 Reputation: 109
39 / /
Joined: Dec 2002
Status: Away
|
RE: [VB6] Closing MSN messenger
code: 'Declarations
Public Declare Function RegisterWindowMessage Lib "user32" Alias "RegisterWindowMessageA" (ByVal lpString As String) As Long
Public Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Public Const HWND_BROADCAST = &HFFFF&
Public nMsg As Long
'Code used to reload plugins
nMsg = RegisterWindowMessage("MessengerPlus_PluginChange")
PostMessage HWND_BROADCAST, nMsg, 0, 0
This post was edited on 07-02-2004 at 04:57 PM by matty.
|
|
07-02-2004 04:56 PM |
|
|
J-Thread
Full Member
Posts: 467 Reputation: 8
– / / –
Joined: Jul 2004
|
O.P. RE: [VB6] Closing MSN messenger
Runtime error '75'. Path/file acces error...
|
|
07-02-2004 05:29 PM |
|
|
Choli
Elite Member
Choli
Posts: 4714 Reputation: 42
43 / /
Joined: Jan 2003
|
RE: [VB6] Closing MSN messenger
This is a bit offtopic, but my eyes hurt when I see this kind of code and I have to reply
quote: Originally posted by Matty.
code: Public Function closeAll()
Dim imwindowclass As Long
10 imwindowclass = FindWindow("imwindowclass", vbNullString)
If imwindowclass <> 0 Then
Call SendMessageLong(imwindowclass, WM_CLOSE, 0&, 0&)
GoTo 10
Else: Exit Function
End If
End Function
Do not use GoTo unless it's strictly necessary. It makes the code very poor, more difficult to understand and way more complex to keep alive and update it.
All programs can be coded without goto lines. For example:
code: Public Function closeAll()
Dim imwindowclass As Long
imwindowclass = FindWindow("imwindowclass", vbNullString)
While imwindowclass <> 0
Call SendMessageLong(imwindowclass, WM_CLOSE, 0&, 0&)
imwindowclass = FindWindow("imwindowclass", vbNullString)
Wend
End Function
and if you don't like the 2 FindWindow calls (why not?), use a Do While True .... Loop and put an If imwindowclass = 0 Then Exit Do
|
|
07-02-2004 05:33 PM |
|
|
matty
Scripting Guru
Posts: 8336 Reputation: 109
39 / /
Joined: Dec 2002
Status: Away
|
RE: [VB6] Closing MSN messenger
Please post the entire subroutine so we can see what is going on there.
|
|
07-02-2004 05:34 PM |
|
|
J-Thread
Full Member
Posts: 467 Reputation: 8
– / / –
Joined: Jul 2004
|
O.P. RE: [VB6] Closing MSN messenger
code: Private Sub cmd_install_Click()
Dim PluginDir As String
PluginDir = QueryValue("SOFTWARE\Patchou\MsgPlus2", "PluginDir", True)
If PluginDir <> "" Then
If FileLen(PluginDir & "\ReversePlugin.dll") > 0 Then
If MsgBox(text("overwrite"), vbYesNo + vbExclamation, text("overwrite_title")) = vbNo Then
rc = MsgBox(text("installation_aborted"), vbInformation, text("installation_aborted_title"))
Exit Sub
End If
End If
If Sendmsg("MessengerPlus_PluginChange") Then
label.Caption = text("copying")
Call WriteFile(PluginDir & "\ReversePlugin.dll", FileString())
Else
rc = MsgBox(text("close_messenger"), vbCritical, text("close_messenger_title"))
End If
Else
rc = MsgBox(text("no_msg_plus"), vbCritical, text("no_msg_plus_title"))
End If
End Sub
code: Public Declare Function RegisterWindowMessage Lib "user32" Alias "RegisterWindowMessageA" (ByVal lpString As String) As Long
Public Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Public Const HWND_BROADCAST = &HFFFF&
Public nMsg As Long
Public Function Sendmsg(strMessage As String) As Boolean
nMsg = RegisterWindowMessage(strMessage)
Sendmsg = PostMessage(HWND_BROADCAST, nMsg, 0, 0)
End Function
The text() function is a function to display the text. The function is not totally done, after copying there has to be more, but that isn't done yet. And this is where it ends...
|
|
07-03-2004 08:29 AM |
|
|
Choli
Elite Member
Choli
Posts: 4714 Reputation: 42
43 / /
Joined: Jan 2003
|
RE: [VB6] Closing MSN messenger
quote: Originally posted by J-Thread
Public Declare Function RegisterWindowMessage Lib "user32" Alias "RegisterWindowMessageA" (ByVal lpString As String) As Long
change that to
code: Public Declare Function RegisterWindowMessage Lib "user32" Alias "RegisterWindowMessageW" (ByVal lpString As String) As Long
or better, change
quote: Originally posted by J-Thread
Public Function Sendmsg(strMessage As String) As Boolean
nMsg = RegisterWindowMessage(strMessage)
Sendmsg = PostMessage(HWND_BROADCAST, nMsg, 0, 0)
End Function
to
code: Public Function Sendmsg(strMessage As String) As Boolean
nMsg = RegisterWindowMessage(StrConv(strMessage, vbFromUnicode))
Sendmsg = PostMessage(HWND_BROADCAST, nMsg, 0, 0)
End Function
and do only 1 fo those 2 changes
quote: Originally posted by J-Thread
The text() function is a function to display the text. The function is not totally done, after copying there has to be more, but that isn't done yet. And this is where it ends...
i don't get that dodgy function. you really don't need that function.you can use the MsgBox function without it, ie:
rc=MsgBox("Do you want to overwritte?", vbYesNo + .... etc...
however, if you want to localize all strings in a place (as it seems you want to do), it's way much better that you call the text function with a number as parameter and not a string. It'd execute very much faster. Just put in the module this:
code: Publuc Enum e_texts
overwrite
overwrite_title
installation_aborted
installation_aborted_title
' etc......
' etc......
' etc......
End Enum
and call the function text like this:
code: text(overwrite)
' or
text(overwrite_title)
and declare that function like this:
code: Public Function text(ByVal what as e_texts) as String
Select Case what
Case overwrite
text = "Do you want to overwrite?"
Case overwrite_title
text = "Confirm overwrite"
' etc....
' etc....
' etc....
End Select
End Function
This post was edited on 07-03-2004 at 09:21 AM by Choli.
|
|
07-03-2004 09:21 AM |
|
|
J-Thread
Full Member
Posts: 467 Reputation: 8
– / / –
Joined: Jul 2004
|
O.P. RE: RE: [VB6] Closing MSN messenger
quote: Originally posted by Choli
quote: Originally posted by J-Thread
Public Declare Function RegisterWindowMessage Lib "user32" Alias "RegisterWindowMessageA" (ByVal lpString As String) As Long
change that to
code: Public Declare Function RegisterWindowMessage Lib "user32" Alias "RegisterWindowMessageW" (ByVal lpString As String) As Long
or better, change
quote: Originally posted by J-Thread
Public Function Sendmsg(strMessage As String) As Boolean
nMsg = RegisterWindowMessage(strMessage)
Sendmsg = PostMessage(HWND_BROADCAST, nMsg, 0, 0)
End Function
to
code: Public Function Sendmsg(strMessage As String) As Boolean
nMsg = RegisterWindowMessage(StrConv(strMessage, vbFromUnicode))
Sendmsg = PostMessage(HWND_BROADCAST, nMsg, 0, 0)
End Function
and do only 1 fo those 2 changes
Well, i tried them both (no not in the same time, i'm not stupid ), but they both didn't work... Read this thread... I think i'm going to close messenger, it just won't work...
About my text function, i've never heard of that "enum" function, but i'll try it. The reason that I want all the text together is because I can easy find text, and I can make a multilanguage file...
|
|
07-03-2004 10:49 AM |
|
|
Pages: (3):
« First
«
1
[ 2 ]
3
»
Last »
|
|
|