Bonjour voila je souhaite enchainer des video pour cela je les ouvre
avec un shell. Je me suis aidé d'un code deja présent sur vbfrance.fr
qui m'aide drolement, apres l'exécution de la premiere video je peut
recuperer la main. Cependant a la fin de la video j'aimerait qu'il me
ferme le programme avec lequel j'ai lu la vidéo... pour ensuite passer
a la suivante...
voici mon code que j'ai fait avec l'aide de Vbfrance
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 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)
Ici j'aimerai que mon programme se ferme tout seul
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
Si quelqun a une idée ca serait simpa