How to close windows media player window ?

L

Lorenzo

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.
 
G

Guest

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
 
F

Fabien

Hi,

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

BR

Fabien Decret
Windows Embedded Consultant

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

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



Post a WM_CLOSE to its main window.

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

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

Lorenzo

Hi,

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

BR

Fabien Decret
Windows Embedded Consultant

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

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
- 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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top