Visualizzazione dei risultati da 1 a 4 su 4
  1. #1

    [VB 6 ] - Attendere la fine dell'istallazione di un programma

    Ragazzi, ho un prob con l'istallazione di un programma!
    Ho crearo un eseguibile che lancia tramite shell() un pacchetto d'istallazione!
    Il prob sta nel fatto che prima di chiudere il mio file exe vorrei attendere la fine dell'istallazione.

    Come posso fare?

  2. #2
    Utente di HTML.it L'avatar di Gugu
    Registrato dal
    Nov 2002
    Messaggi
    523
    Ci sono chiamate alle api e puoi usare shellandWait..
    Ora però non ho il codice sotto mano!

    Lo cerco poi te lop posto.

    Intanto ciao
    Ciao
    Andrea

  3. #3
    Utente di HTML.it L'avatar di Gugu
    Registrato dal
    Nov 2002
    Messaggi
    523

    Funzione ShellAndWait

    Ti allego il codice da inserire in un modulo:

    codice:
    Option Explicit
    
    Public 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
            Public Type PROCESS_INFORMATION
            hProcess As Long
            hThread As Long
            dwProcessId As Long
            dwThreadID As Long
    End Type
        
    Public Declare Function WaitForSingleObject Lib "kernel32" (ByVal _
            hHandle As Long, ByVal dwMilliseconds As Long) As Long
        
    Public 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
        
    Public Declare Function CloseHandle Lib "kernel32" (ByVal _
            hObject As Long) As Long
        
    Public Const NORMAL_PRIORITY_CLASS = &H20&
    Public Const INFINITE = -1&
        
    '#########################################################
    'Funzione per lanciare un programma in sincrono.
    'Il programma lanciato in finestra viene 'atteso' per
    'tutta la sua durata.
    'Una funzione usata per lanciare un programma MS-DOS
    'e attendere la sua fine.
    '1998 by Berardi Paolo
    'Email pberardi@nt.kjws.com
    '#########################################################
    Public Sub ShellAndWait(ByVal RunProg As String)
    
        Dim RetVal As Long
        Dim proc As PROCESS_INFORMATION
        Dim StartInf As STARTUPINFO
        
        
        StartInf.cb = Len(StartInf)
        'Crea sessione del programma da lanciare
        RetVal = CreateProcessA(0&, RunProg, 0&, 0&, 1&, NORMAL_PRIORITY_CLASS, 0&, 0&, StartInf, proc)
        RetVal = WaitForSingleObject(proc.hProcess, INFINITE)
        RetVal = CloseHandle(proc.hProcess)
    
    End Sub
    Poi in un eventuale pulsante, per provare:

    codice:
    Private Sub Command1_Click()
    ShellAndWait ("Calc.exe")
    MsgBox ("Calcolatrice Chiusa!")
    End Sub
    Vorrei segnalare che non è farina del mio sacco.. un po' di tempo fa l'ho scaricato/trovato su internet e uso questa funzione così com'è!

    Ciao
    Ciao
    Andrea

  4. #4
    grazie,ora lo provo!

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.