IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

VB 6 et antérieur Discussion :

Comment savoir si un Shell est terminé ?


Sujet :

VB 6 et antérieur

  1. #1
    Membre à l'essai
    Profil pro
    Inscrit en
    Janvier 2005
    Messages
    24
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2005
    Messages : 24
    Points : 14
    Points
    14
    Par défaut Comment savoir si un Shell est terminé ?
    Bonjour voila je lis une vidéo avec un shell et j'aimerait ensuite qu'il lise une deuxieme video a la suite...

    Mais comment savoir si un shell a finit son action (savoir que la 1ère video est terminé ?

    Merci d'eclairer ma lanterne

  2. #2
    HPJ
    HPJ est déconnecté
    Membre averti

    Profil pro
    Inscrit en
    Mai 2003
    Messages
    260
    Détails du profil
    Informations personnelles :
    Localisation : France, Hérault (Languedoc Roussillon)

    Informations forums :
    Inscription : Mai 2003
    Messages : 260
    Points : 364
    Points
    364
    Par défaut
    Avant de poser une question, merci de chercher dans les rubriques suivantes:
    FAQ VB
    Tutoriaux VB
    Recherche avancée sur le forum

  3. #3
    Membre à l'essai
    Profil pro
    Inscrit en
    Janvier 2005
    Messages
    24
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2005
    Messages : 24
    Points : 14
    Points
    14
    Par défaut
    désolé

    tu veut parler de cet question ?

    Comment lancer un exécutable et reprendre la main quand il a fini ?

  4. #4
    HPJ
    HPJ est déconnecté
    Membre averti

    Profil pro
    Inscrit en
    Mai 2003
    Messages
    260
    Détails du profil
    Informations personnelles :
    Localisation : France, Hérault (Languedoc Roussillon)

    Informations forums :
    Inscription : Mai 2003
    Messages : 260
    Points : 364
    Points
    364
    Par défaut
    Oui.
    Avant de poser une question, merci de chercher dans les rubriques suivantes:
    FAQ VB
    Tutoriaux VB
    Recherche avancée sur le forum

  5. #5
    Membre à l'essai
    Profil pro
    Inscrit en
    Janvier 2005
    Messages
    24
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2005
    Messages : 24
    Points : 14
    Points
    14
    Par défaut
    Avec mon code j'arrive a récuperer la main mais je souhaiterait que Windows Medi player se ferme afin de s'ouvrir avec la nouvelle vidéo... Ou encore mieux, que la vidéo suivant se lance directement (sans devoir fermer et réouvrir mon WMP)

    voici mon code


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    Const HKEY_CLASSES_ROOT = &H80000000
    Const HKEY_CURRENT_USER = &H80000001
    Const HKEY_LOCAL_MACHINE = &H80000002
    Const HKEY_USERS = &H80000003
    Const HKEY_DYN_DATA = &H80000004
     
    Private Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long
     
    Private Declare Function WaitForSingleObject Lib "kernel32" _
       (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
     
    Private Declare Function CloseHandle Lib "kernel32" _
       (ByVal hObject As Long) As Long
     
    Private Declare Function OpenProcess Lib "kernel32" _
       (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, _
        ByVal dwProcessId As Long) As Long
     
     
    Private Const INFINITE = -1&
    Private Const SYNCHRONIZE = &H100000
     
     
    Public Enum HCle
        HKeyLocalMachine = 0
        HKeyCurrentUser = 1
        HKeyClassesRoot = 2
        HKeyUsers = 3
        HKeyDynamicData = 4
    End Enum
     
     
    'pour créer ou ouvrir une clé
    Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" _
        (ByVal HKey As Long, _
         ByVal lpSubKey As String, _
         phkResult As Long) As Long
     
    'pour lire une valeur
    Private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" _
        (ByVal HKey As Long, _
         ByVal lpValueName As String, _
         ByVal lpReserved As Long, _
         lpType As Long, _
         lpData As Any, _
         lpcbData As Long) As Long
     
    Private Sub bt_select_Click()
    CD1.ShowOpen
     
    If CD1.FileName <> "" Then
        listclip.AddItem (CD1.FileName)
    End If
    End Sub
     
    Private Sub Command1_Click()
        Dim extension As String
        Dim pos As Integer
        Dim tmp1 As String
        Dim tmp2 As String
        Dim i As Integer
        Dim iTask As Long, ret As Long, pHandle As Long
     
     
     i = 0
     While i < listclip.ListCount
        tmp2 = ""
        textfichier = listclip.List(i)
        pos = InStrRev(textfichier.Text, ".")
        extension = Right(textfichier.Text, Len(textfichier.Text) - pos + 1)
        Debug.Print "extension :" & extension
        tmp1 = LireValeur(HKeyClassesRoot, extension, "")
        tmp2 = LireValeur(HKeyClassesRoot, tmp1 & "\shell\open\command", "")
     
        tmp2 = Replace(tmp2, "%SystemRoot%", WinDirectory)
        tmp2 = Replace(tmp2, Chr(34) & "%1" & Chr(34), Chr(34) & textfichier.Text & Chr(34))
        tmp2 = Replace(tmp2, "%L", textfichier.Text)
     
        Debug.Print tmp1
        Debug.Print tmp2
        iTask = Shell(tmp2, vbNormalFocus)
     
        pHandle = OpenProcess(SYNCHRONIZE, False, iTask)
     
     
     
        ret = WaitForSingleObject(pHandle, INFINITE)
        ret = CloseHandle(pHandle)
     
        killprocess (iTask)
     
     
        i = i + 1
     
     Wend
     
     
     
    End Sub
     
     
     
    Public Function LireValeur(HK As HCle, Chemin As String, Valeur As String) As String
        Dim lng As Long
        Dim Buff As Long
     
        Buff = 0
        Buff = RegCreateKey(HKConvert(HK), Chemin, lng)
        If Buff = 0 Then RegQueryValueEx lng, Valeur, 0&, 1, 0&, Buff
        If Buff < 2 Then
            LireValeur = ""
            Exit Function
        End If
        LireValeur = String(Buff + 1, " ")
        RegQueryValueEx lng, Valeur, 0&, 1, ByVal LireValeur, Buff
        LireValeur = Left(LireValeur, Buff - 1)
    End Function
     
    Private Function HKConvert(ByVal HK As HCle) As Long
        If HK = 2 Then HKConvert = HKEY_CLASSES_ROOT
        If HK = 1 Then HKConvert = HKEY_CURRENT_USER
        If HK = 0 Then HKConvert = HKEY_LOCAL_MACHINE
        If HK = 3 Then HKConvert = HKEY_USERS
        If HK = 4 Then HKConvert = HKEY_DYN_DATA
    End Function
     
     
     
    Sub killprocess(processid)
     
     
    Dim hProcess, Termine&
     
     
    'On le numéro de son Process
        hProcess = OpenProcess(1, False, processid)
        ' On Ferme le process lancé par un TerminateProcess
        Termine& = TerminateProcess(hProcess, 4)
     
     
    End Sub

    Quelqun as t'il une idée ? c'est la première fois que je traite des process

  6. #6
    Membre éclairé
    Avatar de shwin
    Profil pro
    Inscrit en
    Novembre 2003
    Messages
    568
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations forums :
    Inscription : Novembre 2003
    Messages : 568
    Points : 777
    Points
    777
    Par défaut
    Recherche sur google: shell wait

    premier lien trouvé voici ce que je trouve

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
     
    '***************** Code Start ******************
    'This code was originally written by Terry Kreft.
    'It is not to be altered or distributed,
    'except as part of an application.
    'You are free to use it in any application,
    'provided the copyright notice is left unchanged.
    '
    'Code Courtesy of
    'Terry Kreft
    Private Const STARTF_USESHOWWINDOW& = &H1
    Private Const NORMAL_PRIORITY_CLASS = &H20&
    Private Const INFINITE = -1&
     
    Private Type STARTUPINFO
        cb As Long
        lpReserved As String
        lpDesktop As String
        lpTitle As String
        dwX As Long
        dwY As Long
        dwXSize As Long
        dwYSize As Long
        dwXCountChars As Long
        dwYCountChars As Long
        dwFillAttribute As Long
        dwFlags As Long
        wShowWindow As Integer
        cbReserved2 As Integer
        lpReserved2 As Long
        hStdInput As Long
        hStdOutput As Long
        hStdError As Long
    End Type
     
    Private Type PROCESS_INFORMATION
        hProcess As Long
        hThread As Long
        dwProcessID As Long
        dwThreadID As Long
    End Type
     
    Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal _
        hHandle As Long, ByVal dwMilliseconds As Long) As Long
     
    Private Declare Function CreateProcessA Lib "kernel32" (ByVal _
        lpApplicationName As Long, ByVal lpCommandLine As String, ByVal _
        lpProcessAttributes As Long, ByVal lpThreadAttributes As Long, _
        ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, _
        ByVal lpEnvironment As Long, ByVal lpCurrentDirectory As Long, _
        lpStartupInfo As STARTUPINFO, lpProcessInformation As _
        PROCESS_INFORMATION) As Long
     
    Private Declare Function CloseHandle Lib "kernel32" (ByVal _
        hObject As Long) As Long
     
    Public Sub ShellWait(Pathname As String, Optional WindowStyle As Long)
        Dim proc As PROCESS_INFORMATION
        Dim start As STARTUPINFO
        Dim ret As Long
        ' Initialize the STARTUPINFO structure:
        With start
            .cb = Len(start)
            If Not IsMissing(WindowStyle) Then
                .dwFlags = STARTF_USESHOWWINDOW
                .wShowWindow = WindowStyle
            End If
        End With
        ' Start the shelled application:
        ret& = CreateProcessA(0&, Pathname, 0&, 0&, 1&, _
                NORMAL_PRIORITY_CLASS, 0&, 0&, start, proc)
        ' Wait for the shelled application to finish:
        ret& = WaitForSingleObject(proc.hProcess, INFINITE)
        ret& = CloseHandle(proc.hProcess)
    End Sub
    '***************** Code End ****************
    ensuite il suffit de lancer la fonction shellWait

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
     
    shellwait "C:\monfichier.wmv"
    shellwait "C:\monfichier2.wmv"
    Merci de faire une recherche pour trouvé certaines réponse
    Remoting Context Matters
    Everything in this chapter is 100 percent undocumented. Reliance on these techniques is not supported by either Microsoft, the publisher, or the author of this book. Use at you own risk! If your computer won't work afterwards, your toaster blows up or your car doesn't start, I assume no liability whatsoever: You're now about to enter the uncharted territories of .NET and you do so on your own risk. I can only provide some guidance

  7. #7
    Membre à l'essai
    Profil pro
    Inscrit en
    Janvier 2005
    Messages
    24
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2005
    Messages : 24
    Points : 14
    Points
    14
    Par défaut
    Merci encore désolé mais la procédure ne lance pas la video...

  8. #8
    Membre éclairé
    Avatar de shwin
    Profil pro
    Inscrit en
    Novembre 2003
    Messages
    568
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations forums :
    Inscription : Novembre 2003
    Messages : 568
    Points : 777
    Points
    777
    Par défaut
    montre ton code
    Remoting Context Matters
    Everything in this chapter is 100 percent undocumented. Reliance on these techniques is not supported by either Microsoft, the publisher, or the author of this book. Use at you own risk! If your computer won't work afterwards, your toaster blows up or your car doesn't start, I assume no liability whatsoever: You're now about to enter the uncharted territories of .NET and you do so on your own risk. I can only provide some guidance

  9. #9
    Membre à l'essai
    Profil pro
    Inscrit en
    Janvier 2005
    Messages
    24
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2005
    Messages : 24
    Points : 14
    Points
    14
    Par défaut
    j'ai mit le code que tu ma fourni dans un module
    la prcoedure je l'ai nommé ShellWaiting

    voici ensuite le reste de mon code

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    Private Sub Command1_Click()
     
     
     i = 0
     While i < listclip.ListCount
     
     
        ShellWaiting (listclip.List(i))
     
     
        i = i + 1
     
     
     Wend
     
     
    End Sub
     
    Private Sub bt_select_Click()
    CD1.ShowOpen
     
    If CD1.FileName <> "" Then
        listclip.AddItem (CD1.FileName)
    End If
    End Sub

  10. #10
    Membre éclairé
    Avatar de shwin
    Profil pro
    Inscrit en
    Novembre 2003
    Messages
    568
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations forums :
    Inscription : Novembre 2003
    Messages : 568
    Points : 777
    Points
    777
    Par défaut
    essaye avec ceci

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    ShellWait "C:\Program Files\Windows Media Player\Wmplayer.exe C:\windows\bureau\test.wmv", 3
    Remoting Context Matters
    Everything in this chapter is 100 percent undocumented. Reliance on these techniques is not supported by either Microsoft, the publisher, or the author of this book. Use at you own risk! If your computer won't work afterwards, your toaster blows up or your car doesn't start, I assume no liability whatsoever: You're now about to enter the uncharted territories of .NET and you do so on your own risk. I can only provide some guidance

  11. #11
    Membre à l'essai
    Profil pro
    Inscrit en
    Janvier 2005
    Messages
    24
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2005
    Messages : 24
    Points : 14
    Points
    14
    Par défaut
    Ok ca fonctionne enfin ma vidéo se lance, mais j'arrive pas a passer a la seconde vidéo directement il faut que je ferme le Windows media player

    par exemple quand je fait ça

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     ShellWaiting "C:\Program Files\Windows Media Player\mplayer2.exe C:\Documents and Settings\administrateur\Bureau\test.wmv", 3
        ShellWaiting "C:\Program Files\Windows Media Player\mplayer2.exe C:\Documents and Settings\administrateur\Bureau\autretest.wmv", 3

  12. #12
    Membre éclairé
    Avatar de shwin
    Profil pro
    Inscrit en
    Novembre 2003
    Messages
    568
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations forums :
    Inscription : Novembre 2003
    Messages : 568
    Points : 777
    Points
    777
    Par défaut
    il faut fermer le mplayer mannuellement. Ton code ne peux pas savoir si c'est terminer de jouer (le vidéo), il permet seulement de savoir quand que mplayer est fermer.
    Remoting Context Matters
    Everything in this chapter is 100 percent undocumented. Reliance on these techniques is not supported by either Microsoft, the publisher, or the author of this book. Use at you own risk! If your computer won't work afterwards, your toaster blows up or your car doesn't start, I assume no liability whatsoever: You're now about to enter the uncharted territories of .NET and you do so on your own risk. I can only provide some guidance

  13. #13
    Membre à l'essai
    Profil pro
    Inscrit en
    Janvier 2005
    Messages
    24
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2005
    Messages : 24
    Points : 14
    Points
    14
    Par défaut
    Ok merci d'avoir prit le temps de ma répondre

    Si je comprend bien je peut pas avec mon code faire une "playlist" de video ?

    Ne peut-on pas fermer le windows media player avec VB ? ou la suite du code ne s'effectue qu'apres fermeture du Windows Medi Player ?

  14. #14
    Membre éclairé
    Avatar de shwin
    Profil pro
    Inscrit en
    Novembre 2003
    Messages
    568
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations forums :
    Inscription : Novembre 2003
    Messages : 568
    Points : 777
    Points
    777
    Par défaut
    la suite du coté s'effectue seulement quand tu ferme mplayer.
    Remoting Context Matters
    Everything in this chapter is 100 percent undocumented. Reliance on these techniques is not supported by either Microsoft, the publisher, or the author of this book. Use at you own risk! If your computer won't work afterwards, your toaster blows up or your car doesn't start, I assume no liability whatsoever: You're now about to enter the uncharted territories of .NET and you do so on your own risk. I can only provide some guidance

  15. #15
    Membre à l'essai
    Profil pro
    Inscrit en
    Janvier 2005
    Messages
    24
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2005
    Messages : 24
    Points : 14
    Points
    14
    Par défaut
    Ok et tu n'aurait pas une idée alors pour faire une playlist de video sans utiliser shell...

    En tous cas merci pour cet aide j'aurait au moins approcher de loin les process

Discussions similaires

  1. [AJAX] Comment savoir quand l'action est terminée
    Par tatayecorp dans le forum Général JavaScript
    Réponses: 7
    Dernier message: 13/08/2007, 21h28
  2. [Thread]comment savoir qu'un thread est terminé
    Par david06600 dans le forum Concurrence et multi-thread
    Réponses: 5
    Dernier message: 01/12/2006, 18h39
  3. SAvoir quand un shell est terminé ?
    Par Raphs dans le forum VB 6 et antérieur
    Réponses: 3
    Dernier message: 22/11/2006, 09h00
  4. Unix - Comment savoir si un fichier est ouvert
    Par freddyboy dans le forum C
    Réponses: 7
    Dernier message: 06/10/2004, 15h53
  5. Comment savoir qu'une fonction est standard ?
    Par D[r]eadLock dans le forum C
    Réponses: 5
    Dernier message: 24/03/2003, 14h42

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo