PC Review


Reply
Thread Tools Rate Thread

How to close windows media player window ?

 
 
Lorenzo
Guest
Posts: n/a
 
      29th May 2007
Hi,
I have a main form that launch wmplayer application and play an audio
file.
I used Process.Start method to launch it.

My problem is that when the file is totally played , i don't know
how to close media player window programmatically?

Does anyone know how to do it?
Thanks in advance.

 
Reply With Quote
 
 
 
 
Guest
Posts: n/a
 
      29th May 2007
Post a WM_CLOSE to its main window.


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Managed Code in an Embedded World
www.OpenNETCF.com



"Lorenzo" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi,
> I have a main form that launch wmplayer application and play an audio
> file.
> I used Process.Start method to launch it.
>
> My problem is that when the file is totally played , i don't know
> how to close media player window programmatically?
>
> Does anyone know how to do it?
> Thanks in advance.
>



 
Reply With Quote
 
=?Utf-8?B?ZGJncmljaw==?=
Guest
Posts: n/a
 
      29th May 2007
Here is some example code to help you post the WM_CLOSE message:

[DllImport("Coredll.dll", EntryPoint="SendMessage")]
private static extern int SendMessage(IntPtr hWnd, UInt32 Msg, int wParam,
int lParam);

private const UInt32 WM_CLOSE = 16 ;

Process myProcess; // Create your new process

// Run the media player.

SendMessage(myProcess.MainWindowHandle, WM_CLOSE, 0, 0);

I Hope this helps.

Rick D.
Contractor




"<ctacke/>" wrote:

> Post a WM_CLOSE to its main window.
>
>
> --
>
> Chris Tacke, Embedded MVP
> OpenNETCF Consulting
> Managed Code in an Embedded World
> www.OpenNETCF.com
>
>
>
> "Lorenzo" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Hi,
> > I have a main form that launch wmplayer application and play an audio
> > file.
> > I used Process.Start method to launch it.
> >
> > My problem is that when the file is totally played , i don't know
> > how to close media player window programmatically?
> >
> > Does anyone know how to do it?
> > Thanks in advance.
> >

>
>
>

 
Reply With Quote
 
Fabien
Guest
Posts: n/a
 
      29th May 2007
Hi,

You can use FindWindow to get the handle of your window, check out
this post on my blog:
http://fabdecret.blogspot.com/2007/0...ow-handle.html

BR

Fabien Decret
Windows Embedded Consultant

ADENEO (ADESET)
http://www.adeneo.adetelgroup.com/ | http://fabdecret.blogspot.com/

On 29 mai, 15:41, dbgrick <dbgr...@discussions.microsoft.com> wrote:
> Here is some example code to help you post the WM_CLOSE message:
>
> [DllImport("Coredll.dll", EntryPoint="SendMessage")]
> private static extern int SendMessage(IntPtr hWnd, UInt32 Msg, int wParam,
> int lParam);
>
> private const UInt32 WM_CLOSE = 16 ;
>
> Process myProcess; // Create your new process
>
> // Run the media player.
>
> SendMessage(myProcess.MainWindowHandle, WM_CLOSE, 0, 0);
>
> I Hope this helps.
>
> Rick D.
> Contractor
>
>
>
> "<ctacke/>" wrote:
> > Post a WM_CLOSE to its main window.

>
> > --

>
> > Chris Tacke, Embedded MVP
> > OpenNETCF Consulting
> > Managed Code in an Embedded World
> >www.OpenNETCF.com

>
> > "Lorenzo" <lorenzo.fornare...@framenet.it> wrote in message
> >news:(E-Mail Removed)...
> > > Hi,
> > > I have a main form that launch wmplayer application and play an audio
> > > file.
> > > I used Process.Start method to launch it.

>
> > > My problem is that when the file is totally played , i don't know
> > > how to close media player window programmatically?

>
> > > Does anyone know how to do it?
> > > Thanks in advance.- Masquer le texte des messages précédents -

>
> - Afficher le texte des messages précédents -



 
Reply With Quote
 
Lorenzo
Guest
Posts: n/a
 
      29th May 2007
On 29 Mag, 16:03, Fabien <fab_00_2...@msn.com> wrote:
> Hi,
>
> You can use FindWindow to get the handle of your window, check out
> this post on my blog:http://fabdecret.blogspot.com/2007/0...ow-handle.html
>
> BR
>
> Fabien Decret
> Windows Embedded Consultant
>
> ADENEO (ADESET)http://www.adeneo.adetelgroup.com/|http://fabdecret.blogspot.com/
>
> On 29 mai, 15:41, dbgrick <dbgr...@discussions.microsoft.com> wrote:
>
>
>
> > Here is some example code to help you post the WM_CLOSE message:

>
> > [DllImport("Coredll.dll", EntryPoint="SendMessage")]
> > private static extern int SendMessage(IntPtr hWnd, UInt32 Msg, int wParam,
> > int lParam);

>
> > private const UInt32 WM_CLOSE = 16 ;

>
> > Process myProcess; // Create your new process

>
> > // Run the media player.

>
> > SendMessage(myProcess.MainWindowHandle, WM_CLOSE, 0, 0);

>
> > I Hope this helps.

>
> > Rick D.
> > Contractor

>
> > "<ctacke/>" wrote:
> > > Post a WM_CLOSE to its main window.

>
> > > --

>
> > > Chris Tacke, Embedded MVP
> > > OpenNETCF Consulting
> > > Managed Code in an Embedded World
> > >www.OpenNETCF.com

>
> > > "Lorenzo" <lorenzo.fornare...@framenet.it> wrote in message
> > >news:(E-Mail Removed)...
> > > > Hi,
> > > > I have a main form that launch wmplayer application and play an audio
> > > > file.
> > > > I used Process.Start method to launch it.

>
> > > > My problem is that when the file is totally played , i don't know
> > > > how to close media player window programmatically?

>
> > > > Does anyone know how to do it?
> > > > Thanks in advance.- Masquer le texte des messages précédents -

>
> > - Afficher le texte des messages précédents -- Nascondi testo tra virgolette -

>
> - Mostra testo tra virgolette -


thanks for your help !
I resolved with this snippet
------------------------------------------------------
Dim nWnd As IntPtr
nWnd = GetForegroundWindow()
SendMessage(nWnd, WM_CLOSE, 0, 0)
------------------------------------------------------

i tried also with
------------------------------------------------------
Dim _ip As Integer = myProcess.MainWindowHandle()
SendMessage(_ip, WM_CLOSE, 0, 0)
------------------------------------------------------

but it seems that doesn't work.
Is there an explanation?

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Close Windows Media Player =?Utf-8?B?Q29yZGVsbA==?= Microsoft Excel Misc 1 30th Jan 2007 04:43 AM
Windows Media Player won't go away, keeps reopening when I close it. noah53@juno.com Windows XP General 0 22nd Jul 2006 02:18 AM
Windows Media Player doesn't close =?Utf-8?B?bWlkbmlnaHRibGFkZQ==?= Windows XP Music 1 30th Apr 2005 04:10 PM
WIndows media player keeps playing after close! Jamie Norton Windows XP General 0 7th Jul 2004 02:19 PM
unable to burn CD, window media player close the disc joseph Windows XP Music 2 17th Sep 2003 11:48 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:37 PM.