Remote Call To Close MP (1 Viewer)

elhefe

Portal Member
October 5, 2009
24
0
Home Country
Argentina Argentina
Basically here lies my situation.
I've set up an HTPC, which will also serve as a gamin pc for me and my friends.
basically, its an HTPC with PES2009 on it.
I used a plugin to add PES2009 to the launch menu of MP. but, when I launch it, MP is still in the background eating resources and that has an impact on how the game is displayed :(

So, what do i want to do?
Basically instead of launching PES2009, i will launch my own application that will tell "Hey MP, close now" and then launch PES 2009. and when pes 2009 is closed. it'll open MP again.

I could do this the easy way, by simply KILLING the MP process but i dont want to since it does save settings and ratings etc when you close it. (at least that's what I assume)
What i wanna know how to do, its actually calling the "Shutdown MP" method from outside the app.
I use .NET a lot but never came accross sth like this so if anybody could point me in the right direction it would be very helpful.

Also, if sbdy assures me that i can just KILL the process and it wont mess my settings or anything in MP then im ok.
 

elhefe

Portal Member
October 5, 2009
24
0
Home Country
Argentina Argentina
You can just post the WM_CLOSE windows message to MP's main window.

awesome!!!
im gonna try and find how posting to other apps works!
thnx!!!!!

hey im having trouble making it work anybody could point me in the right direction?
thnx in advance
 

arion_p

Retired Team Member
  • Premium Supporter
  • February 7, 2007
    3,373
    1,626
    Athens
    Home Country
    Greece Greece
    No, but you can find the window by title, and iirc you can also find the main window of a process.
     

    colbsure

    Portal Member
    February 13, 2009
    7
    1
    Home Country
    United Kingdom United Kingdom
    I have written a C++ stub that sends a WM_CLOSE to the mediaportal window. It worked great in windowed mode but not in fullscreen mode.

    Has anybody achieved this with a WM_CLOSE? Failing this I will nuke the MP process.
     

    colbsure

    Portal Member
    February 13, 2009
    7
    1
    Home Country
    United Kingdom United Kingdom
    Okay - I know it's a bit mad responding to my own post but it may help somebody...

    I was wanting to use the Multishortcut plugin to start Maximus Arcade (an emulator front end) - this worked fine but I didn't want media portal hanging around in the background.

    Initially, I wrote a small program which took as parameters a string and an executable path. The program then searched out all windows containing the string and sent a WM_CLOSE to each - afterwards it ran the specified executable (in my case MaximusArcade).

    Unfortunately, testing revealed that the WM_CLOSE didn't seem to be doing the job consistently (I'm not sure why). I was not overly keen on using the TerminateProcess API as it is not generally recommended. Whilst researching I came across this Dr Dobbs article:
    h??p://www.drdobbs.com/windows/184416547?pgno=1
    ...it offers a "safer" alternative to TerminateProcess (see the article for details - it's quite interesting).

    So... I have modified my program to send the WM_CLOSE, wait a user specified number of milliseconds and then check if the window is still present... if it is then a SafeTerminateProcess is used to kill the darn thing. It all seems to be working fine thus far and I am able to switch between Maximus Arcade and Mediaportal cleanly. Next on the list is Comic Rack.

    If anybody wants the source code they are welcome - just PM me.
     

    Spragleknas

    Moderator
  • Team MediaPortal
  • December 21, 2005
    9,474
    1,822
    Located
    Home Country
    Norway Norway
    I don't think responding in your own thread is mad. I think it is a good idea to respond to own thread if you found a solution etc. That way it might (as you write) be useful to others. (Some ppl just write "FIXED" - and leave it at that).

    In short: :D
     

    Users who are viewing this thread

    Top Bottom