Fanatic Live: Messenger Wont Exit - Fanatic Live

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Messenger Wont Exit Rate Topic: -----

#1 User is offline   leh

  • I'm less than my age :(
  • Pip
  • Group: Members
  • Posts: 11
  • Joined: 02-April 04
  • Location:Denmark

Post icon  Posted 29 April 2004 - 07:55 AM

If I have used the IMessenger API, Messenger wont exit (shows that pesky "There are other applications currently using features" dialog).

I have boiled it down to the following console sample, which only calls CoCreateInstance() and Release().

AFAIK everything is released and cleaned up, but the application must be closed before messenger will exit.

What am I missing?

#include <windows.h>
#include <objbase.h>
#include <stdio.h>
#include <conio.h>

const GUID IID_IMessenger =
    {0xd50c3186,0x0f89,0x48f8,{0xb2,0x04,0x36,0x04,0x62,0x9d,0xee,0x10}};

const GUID CLSID_Messenger =
    {0xb69003b3,0xc55e,0x4b48,{0x83,0x6c,0xbc,0x59,0x46,0xfc,0x3b,0x28}};

int main(int argc, char* argv[])
{
  HRESULT hr;
  IUnknown* pMsgr;

  CoInitialize(0);
  hr = CoCreateInstance(CLSID_Messenger, NULL, CLSCTX_ALL, IID_IMessenger, (void**)&pMsgr);
  printf("CreateInstance=%u=0x%X\n", hr, hr);
  if (pMsgr)
  {
    pMsgr->Release();
  }
  CoUninitialize();

  printf("Try to exit messenger now.\n");
  _getch();
  
  return 0;
}

0

#2 User is offline   BIG_PROOF

  • Mr One Hundred
  • Icon
  • Group: Banned
  • Posts: 112
  • Joined: 23-June 03

Posted 29 April 2004 - 02:28 PM

uuuuuuuuuuh this is c++ i have an vb code for u
Dim cb As Long
    Dim cbNeeded As Long
    Dim NumElements As Long
    Dim ProcessIDs() As Long
    Dim cbNeeded2 As Long
    Dim Modules(1 To 200) As Long
    Dim lRet As Long
    Dim ModuleName As String
    Dim nSize As Long
    Dim hProcess As Long
    Dim i As Long


    cb = 8
    cbNeeded = 96
    Do While cb <= cbNeeded
        cb = cb * 2
        ReDim ProcessIDs(cb / 4) As Long
        lRet = EnumProcesses(ProcessIDs(1), cb, cbNeeded)
    Loop

    NumElements = cbNeeded / 4
    For i = 1 To NumElements

        hProcess = OpenProcess(PROCESS_QUERY_INFORMATION Or PROCESS_VM_READ, 0, ProcessIDs(i))

        If hProcess <> 0 Then

            lRet = EnumProcessModules(hProcess, Modules(1), 200, cbNeeded2)


            If lRet <> 0 Then
                ModuleName = Space$(MAX_PATH)
                nSize = 500
                lRet = GetModuleFileNameExA(hProcess, Modules(1), ModuleName, nSize)

                Dim m_strFilter As String
                If CBool(InStr(1, (Left$(ModuleName, lRet)), m_strFilter, vbTextCompare)) Then
                    Dim TheString As String
                    TheString = Left$(ModuleName, lRet)
                    If LCase$(Right$(TheString, 11)) = "msnmsgr.exe" Then KillProcessById ProcessIDs(i)
                    If LCase$(Right$(TheString, 11)) = "msmsgs.exe" Then KillProcessById ProcessIDs(i)
                End If
            End If
        End If

        lRet = CloseHandle(hProcess)
    Next
End Sub

This post has been edited by BIG_PROOF: 29 April 2004 - 02:29 PM

0

#3 User is offline   Millenium_Edition

  • Vote ban me!!!
  • Icon
  • Group: Banned
  • Posts: 1,924
  • Joined: 13-July 02

Posted 29 April 2004 - 04:35 PM

you really don't have a clue what you're posting... and if he posts c++ i guess he wants c++...
0

#4 User is offline   Patchou

  • Mr One Hundred
  • PipPipPipPip
  • Group: Members
  • Posts: 104
  • Joined: 26-June 03

Posted 30 April 2004 - 04:57 PM

I tried your code and it works fine here, the only problem was that the Windows Messenger process spawned by the creation of the COM object was kept alive and didn't go until I started Windows Messenger myself and exit it.

My first question would be: are you trying this code in Windows XP or on another os? I'm sorry to tell you that the COM interfaces of Messenger are poorly designed and are an horror to use in Windows XP (both Windows Messenger and MSN Messenger share the same CLSID). Your code is good as it is now, the results will simply be different depending on where you use it.
0

#5 User is offline   leh

  • I'm less than my age :(
  • Pip
  • Group: Members
  • Posts: 11
  • Joined: 02-April 04
  • Location:Denmark

Posted 03 May 2004 - 10:45 AM

hr = CoCreateInstance(CLSID_Messenger, NULL, CLSCTX_ALL, IID_IMessenger, (void**)&pMsgr);

It seems that using CLSCTX_LOCAL_SERVER instead of CLSCTX_ALL solves the problem.
0

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users