PDA

Click to See Complete Forum and Search --> : HOWTO Shutdown/Terminate Windows MediaPlayer from VB program?


Thom
Nov 10th, 2000, 08:35 AM
Sheesh..seems I’ve managed to stump the experts here!

What I’m Trying to do in my VB networked program is use ShellExecute to launch the Windows Media Player, and then shut it down from the program.

First the code to LAUNCH:

Dim ItemFile As String
ItemFile = "Training1.mpg"
Call ShellExecute(hwnd, "Open", ItemFile, "", App.Path & "\Items\", 1)
bIsPlaying = True ' SETS THE MULTIMEDIA FLAG!!!

So now I have the Media running; what I WANT to have happen is when the user clicks the “Next Item” button, code in the click event ENDS/CLOSES/KILLS the Windows Media Player!

I’ve looked at the SendMessage, TerminateProcess, and CloseHandle API calls but NONE of them work! Does ANYONE have an idea of how to simply close the MediaPlayer with code from the VB program that will work in Windows 98 AND NT 4.0?? I’d really appreciate any help. Thanks!

matbrophy
Nov 10th, 2000, 02:38 PM
Have you tried?

Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hwndNewParent As Long) As Long
Private Const WM_CLOSE = &H10

Terminate = SendMessage(hWnd, WM_CLOSE, 0, 0)

It works for me in Win98

Matthew (Matbrophy@bigfoot.com)
VB6 Pro