-----Message d'origine-----
Honnetement, ce contrôle ActiveX marche vraiment mal,
1.0 il y à quelque mois et soit ca marche pour un titre
soit ca plante directement en fermant l'application qui
plus un grésillement se fait entendre à chaque début de
Evitez ce truc pour un usage professionnel. Moi je fais
une ligne de commande DOS qui execute
avec une pipe pour récupérer le pourcentage dans une
module nommé MyDos bien connu. Depuis les encodages sont
l'utilisateur ne voit pas aucune fenetre DOS a part mon
ceux qui veulent des idées la dessus. Idem pour ToolAme
Encoder)
@+
Jonathan
.
-----Message d'origine-----
Honnetement, ce contrôle ActiveX marche vraiment mal,
1.0 il y à quelque mois et soit ca marche pour un titre
soit ca plante directement en fermant l'application qui
plus un grésillement se fait entendre à chaque début de
Evitez ce truc pour un usage professionnel. Moi je fais
une ligne de commande DOS qui execute
avec une pipe pour récupérer le pourcentage dans une
module nommé MyDos bien connu. Depuis les encodages sont
l'utilisateur ne voit pas aucune fenetre DOS a part mon
ceux qui veulent des idées la dessus. Idem pour ToolAme
Encoder)
@+
Jonathan
.
-----Message d'origine-----
Honnetement, ce contrôle ActiveX marche vraiment mal,
1.0 il y à quelque mois et soit ca marche pour un titre
soit ca plante directement en fermant l'application qui
plus un grésillement se fait entendre à chaque début de
Evitez ce truc pour un usage professionnel. Moi je fais
une ligne de commande DOS qui execute
avec une pipe pour récupérer le pourcentage dans une
module nommé MyDos bien connu. Depuis les encodages sont
l'utilisateur ne voit pas aucune fenetre DOS a part mon
ceux qui veulent des idées la dessus. Idem pour ToolAme
Encoder)
@+
Jonathan
.
-----Message d'origine-----
Dans une form (1 textbox + 4 boutons)
Private WithEvents MyDOS As DOSClass
Private Sub CmdQuitter_Click()
Unload Me
End Sub
Private Sub Form_Load()
Set MyDOS = New DOSClass
End Sub
Private Sub Form_Unload(Cancel As Integer)
MyDOS.ClosedCommand
Set MyDOS = Nothing
End Sub
Private Sub MyDOS_ReceiveOutputs(CommandOutputs As String)
If CommandOutputs <> "" Then TextDos = "": TextDos =
End Sub
Private Sub Command1_Click()
TextDos = ""
MyDOS.CommandLine = "cmd.exe /C dir c:"
MyDOS.ExecuteCommand
End Sub
Private Sub Command2_Click()
TextDos = ""
MyDOS.CommandLine = "net.exe"
MyDOS.ExecuteCommand
End Sub
Private Sub Command3_Click()
TextDos = ""
MyDOS.CommandLine = "C:lame.exe " & Chr(34) & _
"Fichier.wav" & Chr(34) & " " & Chr(34)
MyDOS.ExecuteCommand
End Sub
Private Sub Command4_Click()
CommonDialog1.DialogTitle = "Choisir un programme de
CommonDialog1.Filter = " Programmes |*.exe"
CommonDialog1.ShowOpen
If CommonDialog1.FileName <> "" Then
TextDos = ""
MyDOS.CommandLine = CommonDialog1.FileName
MyDOS.ExecuteCommand
End If
End Sub
Dans un module:
Option Explicit
Private Declare Function CreatePipe Lib "kernel32"
phWritePipe As Long, lpPipeAttributes As Any, ByVal nSize
Private Declare Function ReadFile Lib "kernel32" (ByVal
lpBuffer As String, ByVal nNumberOfBytesToRead As Long,
As Long, ByVal lpOverlapped As Any) As Long
Private Type SECURITY_ATTRIBUTES
nLength As Long
lpSecurityDescriptor As Long
bInheritHandle As Long
End Type
Private Type STARTUPINFO
cb As Long
lpReserved As Long
lpDesktop As Long
lpTitle As Long
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 CreateProcessA Lib "kernel32"
lpApplicationName As Long, ByVal lpCommandLine As String,
lpProcessAttributes As SECURITY_ATTRIBUTES,
SECURITY_ATTRIBUTES, ByVal bInheritHandles As Long, ByVal
Long, ByVal lpEnvironment As Long, ByVal
lpStartupInfo As STARTUPINFO, lpProcessInformation As
As Long
Private Declare Function TerminateProcess Lib "kernel32" _
(ByVal hProcess As Long, _
ByVal uExitCode As Long) As Long
Private Declare Function CloseHandle Lib "kernel32"
As Long
Private Const NORMAL_PRIORITY_CLASS = &H20&
Private Const STARTF_USESTDHANDLES = &H100&
Private Const STARTF_USESHOWWINDOW = &H1
Private mCommand As String 'Variable
la ligne de commande
Private mOutputs As String 'Variable
lecture du texte renvoié
Private ProcI As PROCESS_INFORMATION 'Process
Private HLecturePipe As Long 'Handle
Private HEcriturePipe As Long 'Handle
Public Event ReceiveOutputs(CommandOutputs As String)
Public Property Let CommandLine(DOSCommand As String)
mCommand = DOSCommand
End Property
Public Property Get CommandLine() As String
CommandLine = mCommand
End Property
Public Property Get Outputs()
Outputs = mOutputs
End Property
Public Function ExecuteCommand() As String
Dim Result As Long
Dim Start As STARTUPINFO
Dim Sa As SECURITY_ATTRIBUTES
Dim LngOctetRec As Long
Dim strBuff As String * 256
If Len(mCommand) = 0 Then
MsgBox "La commande à lancer n'a pas été
Exit Function
End If
Sa.nLength = Len(Sa)
Sa.bInheritHandle = 1&
Sa.lpSecurityDescriptor = 0&
If CreatePipe(HLecturePipe, HEcriturePipe, Sa, 0) = 0
MsgBox "Erreur de création du Pipe. Erreurr: " &
vbCritical
Exit Function
End If
Start.cb = Len(Start)
Start.dwFlags = STARTF_USESTDHANDLES Or
Start.hStdOutput = HEcriturePipe
Start.hStdError = HEcriturePipe
If CreateProcessA(0&, mCommand, Sa, Sa, 1&,
0&, Start, ProcI) <> 1 Then
Result = CloseHandle(HLecturePipe)
Result = CloseHandle(HEcriturePipe)
MsgBox "Fichier ou commande non trouvé.",
Exit Function
End If
Result = CloseHandle(HEcriturePipe)
mOutputs = ""
Do
Result = ReadFile(HLecturePipe, strBuff, 256,
mOutputs = mOutputs & Left(strBuff, LngOctetRec)
RaiseEvent ReceiveOutputs(Left(strBuff,
DoEvents
Loop While Result <> 0
Result = CloseHandle(ProcI.hProcess)
Result = CloseHandle(ProcI.hThread)
Result = CloseHandle(HLecturePipe)
ExecuteCommand = mOutputs
End Function
Public Sub ClosedCommand()
Dim Result As Long
TerminateProcess ProcI.hProcess, 0
Result = CloseHandle(ProcI.hProcess)
Result = CloseHandle(ProcI.hThread)
Result = CloseHandle(HLecturePipe)
End Sub
Apres tu récupères les valeurs de la textbox pour
progression .
@+
Jonathan
.
-----Message d'origine-----
Dans une form (1 textbox + 4 boutons)
Private WithEvents MyDOS As DOSClass
Private Sub CmdQuitter_Click()
Unload Me
End Sub
Private Sub Form_Load()
Set MyDOS = New DOSClass
End Sub
Private Sub Form_Unload(Cancel As Integer)
MyDOS.ClosedCommand
Set MyDOS = Nothing
End Sub
Private Sub MyDOS_ReceiveOutputs(CommandOutputs As String)
If CommandOutputs <> "" Then TextDos = "": TextDos =
End Sub
Private Sub Command1_Click()
TextDos = ""
MyDOS.CommandLine = "cmd.exe /C dir c:"
MyDOS.ExecuteCommand
End Sub
Private Sub Command2_Click()
TextDos = ""
MyDOS.CommandLine = "net.exe"
MyDOS.ExecuteCommand
End Sub
Private Sub Command3_Click()
TextDos = ""
MyDOS.CommandLine = "C:lame.exe " & Chr(34) & _
"Fichier.wav" & Chr(34) & " " & Chr(34)
MyDOS.ExecuteCommand
End Sub
Private Sub Command4_Click()
CommonDialog1.DialogTitle = "Choisir un programme de
CommonDialog1.Filter = " Programmes |*.exe"
CommonDialog1.ShowOpen
If CommonDialog1.FileName <> "" Then
TextDos = ""
MyDOS.CommandLine = CommonDialog1.FileName
MyDOS.ExecuteCommand
End If
End Sub
Dans un module:
Option Explicit
Private Declare Function CreatePipe Lib "kernel32"
phWritePipe As Long, lpPipeAttributes As Any, ByVal nSize
Private Declare Function ReadFile Lib "kernel32" (ByVal
lpBuffer As String, ByVal nNumberOfBytesToRead As Long,
As Long, ByVal lpOverlapped As Any) As Long
Private Type SECURITY_ATTRIBUTES
nLength As Long
lpSecurityDescriptor As Long
bInheritHandle As Long
End Type
Private Type STARTUPINFO
cb As Long
lpReserved As Long
lpDesktop As Long
lpTitle As Long
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 CreateProcessA Lib "kernel32"
lpApplicationName As Long, ByVal lpCommandLine As String,
lpProcessAttributes As SECURITY_ATTRIBUTES,
SECURITY_ATTRIBUTES, ByVal bInheritHandles As Long, ByVal
Long, ByVal lpEnvironment As Long, ByVal
lpStartupInfo As STARTUPINFO, lpProcessInformation As
As Long
Private Declare Function TerminateProcess Lib "kernel32" _
(ByVal hProcess As Long, _
ByVal uExitCode As Long) As Long
Private Declare Function CloseHandle Lib "kernel32"
As Long
Private Const NORMAL_PRIORITY_CLASS = &H20&
Private Const STARTF_USESTDHANDLES = &H100&
Private Const STARTF_USESHOWWINDOW = &H1
Private mCommand As String 'Variable
la ligne de commande
Private mOutputs As String 'Variable
lecture du texte renvoié
Private ProcI As PROCESS_INFORMATION 'Process
Private HLecturePipe As Long 'Handle
Private HEcriturePipe As Long 'Handle
Public Event ReceiveOutputs(CommandOutputs As String)
Public Property Let CommandLine(DOSCommand As String)
mCommand = DOSCommand
End Property
Public Property Get CommandLine() As String
CommandLine = mCommand
End Property
Public Property Get Outputs()
Outputs = mOutputs
End Property
Public Function ExecuteCommand() As String
Dim Result As Long
Dim Start As STARTUPINFO
Dim Sa As SECURITY_ATTRIBUTES
Dim LngOctetRec As Long
Dim strBuff As String * 256
If Len(mCommand) = 0 Then
MsgBox "La commande à lancer n'a pas été
Exit Function
End If
Sa.nLength = Len(Sa)
Sa.bInheritHandle = 1&
Sa.lpSecurityDescriptor = 0&
If CreatePipe(HLecturePipe, HEcriturePipe, Sa, 0) = 0
MsgBox "Erreur de création du Pipe. Erreurr: " &
vbCritical
Exit Function
End If
Start.cb = Len(Start)
Start.dwFlags = STARTF_USESTDHANDLES Or
Start.hStdOutput = HEcriturePipe
Start.hStdError = HEcriturePipe
If CreateProcessA(0&, mCommand, Sa, Sa, 1&,
0&, Start, ProcI) <> 1 Then
Result = CloseHandle(HLecturePipe)
Result = CloseHandle(HEcriturePipe)
MsgBox "Fichier ou commande non trouvé.",
Exit Function
End If
Result = CloseHandle(HEcriturePipe)
mOutputs = ""
Do
Result = ReadFile(HLecturePipe, strBuff, 256,
mOutputs = mOutputs & Left(strBuff, LngOctetRec)
RaiseEvent ReceiveOutputs(Left(strBuff,
DoEvents
Loop While Result <> 0
Result = CloseHandle(ProcI.hProcess)
Result = CloseHandle(ProcI.hThread)
Result = CloseHandle(HLecturePipe)
ExecuteCommand = mOutputs
End Function
Public Sub ClosedCommand()
Dim Result As Long
TerminateProcess ProcI.hProcess, 0
Result = CloseHandle(ProcI.hProcess)
Result = CloseHandle(ProcI.hThread)
Result = CloseHandle(HLecturePipe)
End Sub
Apres tu récupères les valeurs de la textbox pour
progression .
@+
Jonathan
.
-----Message d'origine-----
Dans une form (1 textbox + 4 boutons)
Private WithEvents MyDOS As DOSClass
Private Sub CmdQuitter_Click()
Unload Me
End Sub
Private Sub Form_Load()
Set MyDOS = New DOSClass
End Sub
Private Sub Form_Unload(Cancel As Integer)
MyDOS.ClosedCommand
Set MyDOS = Nothing
End Sub
Private Sub MyDOS_ReceiveOutputs(CommandOutputs As String)
If CommandOutputs <> "" Then TextDos = "": TextDos =
End Sub
Private Sub Command1_Click()
TextDos = ""
MyDOS.CommandLine = "cmd.exe /C dir c:"
MyDOS.ExecuteCommand
End Sub
Private Sub Command2_Click()
TextDos = ""
MyDOS.CommandLine = "net.exe"
MyDOS.ExecuteCommand
End Sub
Private Sub Command3_Click()
TextDos = ""
MyDOS.CommandLine = "C:lame.exe " & Chr(34) & _
"Fichier.wav" & Chr(34) & " " & Chr(34)
MyDOS.ExecuteCommand
End Sub
Private Sub Command4_Click()
CommonDialog1.DialogTitle = "Choisir un programme de
CommonDialog1.Filter = " Programmes |*.exe"
CommonDialog1.ShowOpen
If CommonDialog1.FileName <> "" Then
TextDos = ""
MyDOS.CommandLine = CommonDialog1.FileName
MyDOS.ExecuteCommand
End If
End Sub
Dans un module:
Option Explicit
Private Declare Function CreatePipe Lib "kernel32"
phWritePipe As Long, lpPipeAttributes As Any, ByVal nSize
Private Declare Function ReadFile Lib "kernel32" (ByVal
lpBuffer As String, ByVal nNumberOfBytesToRead As Long,
As Long, ByVal lpOverlapped As Any) As Long
Private Type SECURITY_ATTRIBUTES
nLength As Long
lpSecurityDescriptor As Long
bInheritHandle As Long
End Type
Private Type STARTUPINFO
cb As Long
lpReserved As Long
lpDesktop As Long
lpTitle As Long
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 CreateProcessA Lib "kernel32"
lpApplicationName As Long, ByVal lpCommandLine As String,
lpProcessAttributes As SECURITY_ATTRIBUTES,
SECURITY_ATTRIBUTES, ByVal bInheritHandles As Long, ByVal
Long, ByVal lpEnvironment As Long, ByVal
lpStartupInfo As STARTUPINFO, lpProcessInformation As
As Long
Private Declare Function TerminateProcess Lib "kernel32" _
(ByVal hProcess As Long, _
ByVal uExitCode As Long) As Long
Private Declare Function CloseHandle Lib "kernel32"
As Long
Private Const NORMAL_PRIORITY_CLASS = &H20&
Private Const STARTF_USESTDHANDLES = &H100&
Private Const STARTF_USESHOWWINDOW = &H1
Private mCommand As String 'Variable
la ligne de commande
Private mOutputs As String 'Variable
lecture du texte renvoié
Private ProcI As PROCESS_INFORMATION 'Process
Private HLecturePipe As Long 'Handle
Private HEcriturePipe As Long 'Handle
Public Event ReceiveOutputs(CommandOutputs As String)
Public Property Let CommandLine(DOSCommand As String)
mCommand = DOSCommand
End Property
Public Property Get CommandLine() As String
CommandLine = mCommand
End Property
Public Property Get Outputs()
Outputs = mOutputs
End Property
Public Function ExecuteCommand() As String
Dim Result As Long
Dim Start As STARTUPINFO
Dim Sa As SECURITY_ATTRIBUTES
Dim LngOctetRec As Long
Dim strBuff As String * 256
If Len(mCommand) = 0 Then
MsgBox "La commande à lancer n'a pas été
Exit Function
End If
Sa.nLength = Len(Sa)
Sa.bInheritHandle = 1&
Sa.lpSecurityDescriptor = 0&
If CreatePipe(HLecturePipe, HEcriturePipe, Sa, 0) = 0
MsgBox "Erreur de création du Pipe. Erreurr: " &
vbCritical
Exit Function
End If
Start.cb = Len(Start)
Start.dwFlags = STARTF_USESTDHANDLES Or
Start.hStdOutput = HEcriturePipe
Start.hStdError = HEcriturePipe
If CreateProcessA(0&, mCommand, Sa, Sa, 1&,
0&, Start, ProcI) <> 1 Then
Result = CloseHandle(HLecturePipe)
Result = CloseHandle(HEcriturePipe)
MsgBox "Fichier ou commande non trouvé.",
Exit Function
End If
Result = CloseHandle(HEcriturePipe)
mOutputs = ""
Do
Result = ReadFile(HLecturePipe, strBuff, 256,
mOutputs = mOutputs & Left(strBuff, LngOctetRec)
RaiseEvent ReceiveOutputs(Left(strBuff,
DoEvents
Loop While Result <> 0
Result = CloseHandle(ProcI.hProcess)
Result = CloseHandle(ProcI.hThread)
Result = CloseHandle(HLecturePipe)
ExecuteCommand = mOutputs
End Function
Public Sub ClosedCommand()
Dim Result As Long
TerminateProcess ProcI.hProcess, 0
Result = CloseHandle(ProcI.hProcess)
Result = CloseHandle(ProcI.hThread)
Result = CloseHandle(HLecturePipe)
End Sub
Apres tu récupères les valeurs de la textbox pour
progression .
@+
Jonathan
.