close divx player using a button on a form

Hi I was wondering if you could help me I've got a form with a button on it that opens the Divxplayer via the shell command, but once the divx finishes playing it just stops on the screen. I would like to shut down the divx player using another button on the form.How would I do this and removing all traces from the cpu memoery?
GarstuardAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mike TomlinsonMiddle School Assistant TeacherCommented:
Option Explicit

Private Const PROCESS_ALL_ACCESS = &H1F0FFF
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function GetExitCodeProcess Lib "kernel32" (ByVal hProcess As Long, lpExitCode As Long) As Long
Private Declare Sub TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long)

Private taskID As Double

Private Sub Form_Load()
    Command2.Enabled = False
End Sub

Private Sub Command1_Click()
    If taskID <> 0 Then
        KillShell taskID
    End If
    taskID = Shell("notepad.exe", vbNormalFocus)
    Command2.Enabled = True
End Sub

Private Sub Command2_Click()
    If taskID <> 0 Then
        KillShell taskID
        taskID = 0
    End If
    Command2.Enabled = False
End Sub

Private Sub KillShell(ByVal taskID As Double)
    On Error Resume Next

    Dim hProcess As Long
    Dim lExitCode As Long
    Dim lRet As Long

    If taskID <> 0 Then
        hProcess = OpenProcess(PROCESS_ALL_ACCESS, 0&, taskID)
        If hProcess <> 0 Then
            GetExitCodeProcess hProcess, lExitCode
            If lExitCode <> 0 Then
                TerminateProcess hProcess, lExitCode
            End If
        End If
    End If
End Sub
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
GarstuardAuthor Commented:
Big apologies for not responding to the kind solution provided. It was a mad time for what we were developing at the time...working 24hrs a day. Thanks for taking the time to post, I have to admit we found a different work around for that solution but i'm sure the one listed works.
0
DanRollinsCommented:
If you have a few minutes to briefly describe the alternate technique, doing so could help improve the EE Solutions database.  Thanks!
-- DanRollins EE Page Editor
0
GarstuardAuthor Commented:
Sorry, I should have been more specific, due to time management at the time and changing our development strategy, the work-around we used was by using a developer to embed a vlc player into flash program. Subsequently [and i'm afraid i'm not party to his code] each .divx files now auto-closes upon completion.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.