Soyez le premier à donner votre avis sur cette source.
Snippet vu 20 706 fois - Téléchargée 34 fois
#Region " Constantes " Public Const SW_HIDE As Short = 0 Public Const SW_SHOWNORMAL As Short = 1 ' Restores Window if Minimized or 'Minimized Public Const SW_SHOWMINIMIZE As Short = 2 ' Maximized Public Const SW_SHOWMAXIMIZE As Short = 3 'NoActivate Public Const SW_SHOWNOACTIVE As Short = 4 #End Region #Region " API " Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _ (ByVal hwnd As Integer, ByVal lpOperation As String, ByVal lpFile As String, _ ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Integer) _ As Integer Private Declare Function FindExecutable Lib "shell32.dll" Alias "FindExecutableA" _ (ByVal lpFile As String, ByVal lpDirectory As String, ByVal lpResult As String) As Integer #End Region Public Const csExe$ = ".exe" Public Sub sbShell(ByVal S As String, Optional ByVal Args As String = "", _ Optional ByVal ProcStyle As Short = SW_SHOWNORMAL) Try Dim MyProcess As New ProcessStartInfo(S, Args) Select Case ProcStyle Case SW_SHOWNORMAL MyProcess.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal Case SW_HIDE MyProcess.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden Case SW_SHOWMAXIMIZE MyProcess.WindowStyle = System.Diagnostics.ProcessWindowStyle.Maximized Case SW_SHOWMINIMIZE MyProcess.WindowStyle = System.Diagnostics.ProcessWindowStyle.Minimized End Select MyProcess.UseShellExecute = True Dim P As Process = Process.Start(MyProcess) Do Application.DoEvents() System.Threading.Thread.CurrentThread.Sleep(1) Loop Until P.HasExited Catch ex As Exception End Try End Sub Public Sub sbLanceFichier(ByVal hWnd As Integer, ByVal Fichier As String, _ Optional ByVal bMax As Boolean = False, Optional ByVal typAff As Short = SW_SHOWNORMAL, _ Optional ByVal bWait As Boolean = False) Try Dim RetVal As Integer Dim Ext$ = System.IO.Path.GetExtension(Fichier$) If Ext <> csExe And Ext <> "" Then Dim Rep As String, SH As Short = SW_SHOWNORMAL If bMax Then SH = SW_SHOWMAXIMIZE ElseIf typAff <> SW_SHOWNORMAL Then SH = typAff End If Dim Exec As String = New String(Chr(0), 255) RetVal = FindExecutable(Fichier, Rep, Exec) If RetVal > 32 Or Trim$(Exec) <> "" Then If Rep Is Nothing Then Rep = Left(Fichier, 3) End If Exec = Left(Exec, InStr(Exec, Chr(0)) - 1) If Not bWait Then ShellExecute(hWnd, "open", Exec, Fichier, _ Rep, SH) Else modProcess.sbShell(Exec, Fichier, SH) End If End If ElseIf Ext <> "" Then sbShell(Fichier, , typAff) Else sbShell("explorer.exe", "/e,""" & Fichier & """", typAff) End If Catch ex As Exception gMsg.sbMsgCr(ex.Message, "modShell.sbLanceFichier") End Try End Sub
23 oct. 2006 à 17:32
23 janv. 2006 à 20:40
Tu me diras si tu en as été averti.
Depuis 15h, le serveur de mail surchauffe, alors il est possible que le mail qui averti t'arrive ... mais un peu plus tard.
Confirme moi, stp, par message privé.
Jack
23 janv. 2006 à 17:14
Le Sleep 1 Fonctionne parfaitement sans surcharger le processeur
En plus j'avais oublier de préciser le thread sur lequel faire le sleep
Je modifie le code en conséquence
23 janv. 2006 à 17:08
J'ai besoins de l'équivalent :
Shell Fichier,wait:=true
Sans bloquer l'appli
pour que mon prog attende la fin de l'exécution, tout en conservant l'interface active
c'est pour ça que j'ai du mal à réaliser ça avec le callback car le callback semble terminer la procedure en cours sans attendre la fin de l'exécution
23 janv. 2006 à 16:45
Mets-donc sleep(1) au lieu de 100 ! :)
Vous n'êtes pas encore membre ?
inscrivez-vous, c'est gratuit et ça prend moins d'une minute !
Les membres obtiennent plus de réponses que les utilisateurs anonymes.
Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.
Le fait d'être membre vous permet d'avoir des options supplémentaires.