View Full Version : VB troppo complesso????
texerasmo
23-04-2004, 16:29
Ciao a tutti premetto che non conosco vb6 (ne so qualcosa)
ci chiedo questo aiuto..
Devo far un .exe che mi lanci un .exe ovvere mi installi java.
al fine di questo mi lanci un file bat.
Tu tto questo è molto complesso?
c'è qualcuno di voi che puo aiutarmi?
Grazie...
Shell "c.\cartella\file.exe"
questo per lanciare un exe o qualsiasi altro file. Per intercettare quando -file.exe- ha finito l'execuzione la cosa si complica un pò...
Bye!
Per vedere se un exe è in esecuzione:
Private Const TH32CS_SNAPPROCESS = 2
Private Declare Function CreateToolhelp32Snapshot Lib "kernel32" (ByVal dwFlags As Long, ByVal th32ProcessID As Long) As Long
Private Declare Function Process32First Lib "kernel32" (ByVal hSnapshot As Long, lppe As PROCESSENTRY32) As Long
Private Declare Function Process32Next Lib "kernel32" (ByVal hSnapshot As Long, lppe As PROCESSENTRY32) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Type PROCESSENTRY32
dwSize As Long
cntUsage As Long
th32ProcessID As Long
th32DefaultHeapID As Long
th32ModuleID As Long
cntThreads As Long
th32ParentProcessID As Long
pcPriClassBase As Long
dwFlags As Long
szExeFile As String * 260
End Type
Public Function IsRunning(ByVal sExe As String) As Boolean
'vedo se un applicazione è in esecuzione
Dim vProc As Variant
Dim vVetAux As Variant
Dim nI As Integer
Dim nLen As Integer
vProc = GetListProcesses()
nLen = UBound(vProc)
Do
nI = nI + 1
vVetAux = Split(vProc(nI), Chr$(0))
If UCase$(sExe) = UCase$(vVetAux(0)) Then
IsRunning = True
End If
Loop Until nI = nLen Or IsRunning = True
End Function
Private Function GetListProcesses() As Variant
'restituisce tutti i processi attivi
Dim lProcessSnap As Long
Dim pe32 As PROCESSENTRY32
Dim sString As String
Dim sListProcesses() As String
lProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0)
If lProcessSnap = -1 Then
Exit Function
End If
pe32.dwSize = Len(pe32)
'carico tutti i processi
If Process32First(lProcessSnap, pe32) <> 0 Then
ReDim sListProcesses(0)
Do
sString = Left$(pe32.szExeFile, InStr(pe32.szExeFile, Chr$(0)) - 1)
ReDim Preserve sListProcesses(UBound(sListProcesses) + 1)
sListProcesses(UBound(sListProcesses)) = sString & Chr$(0) & pe32.th32ProcessID
Loop While Process32Next(lProcessSnap, pe32)
End If
GetListProcesses = sListProcesses
'tolgo handle alla funzione
Call CloseHandle(lProcessSnap)
End Function
texerasmo
26-04-2004, 10:39
tnks,
proverò, fors e ho trovato un alternativa con i file bat
vBulletin® v3.6.4, Copyright ©2000-2025, Jelsoft Enterprises Ltd.