Oppure

Loading
21/08/09 14:13
fusebyte
Usando questa funzione ottengo questo "error runtime" .
Private Sub Form_Load()
TerminateProcess ("Icon.exe")
End Sub

Public Sub TerminateProcess(ByVal ProcessName As String)

Dim oLoc
Dim oServ
Dim oObjectSet
Dim oProc
Dim sWQL As String
Yes = True
' genera la query WQL
sWQL = "SELECT * FROM Win32_Process WHERE Name = '" & ProcessName & "'"

' oggetto locator
Set oLoc = CreateObject("WbemScripting.sWbemLocator")
Set oServ = oLoc.ConnectServer(".", "root\cimv2")
Set oObjectSet = oServ.ExecQuery(sWQL)

For Each oProc In oObjectSet
If Yes = True Then oProc.Terminate <---error runtime 2147217406
Next

Set oProc = Nothing
Set oObjectSet = Nothing
Set oServ = Nothing
Set oLoc = Nothing
End Sub



Il codice funziona,killa l'applicazone anche se ha più instanze,ma in chiusura se ne esce con questo errore,del quale non riesco ad trovare niente al riguardo.
Sapreste dirmi dove agire per sistemare le cose?

Grazie
Ultima modifica effettuata da fusebyte 21/08/09 14:18
aaa
21/08/09 18:32
fusebyte
ad trovare = a trovare
chiedo venia per l'errore grammaticale.

Ciao
aaa
01/09/09 9:08
fusebyte
RISOLTO problema oProc.Terminate error runtime!
For Each oProc In oObjectSet
If Yes = True Then oProc.Terminate '<--- error runtime
Next


Primo non dichiaravo come Boolean la var YES
Secondo non riportavo la condizione a FALSE

Dim Yes as Boolean

For Each oProc In oObjectSet
If Yes = True Then oProc.Terminate
Yes = False
Next


Error RunTime 2147217406 sparito ! :-))

Ciao
Ultima modifica effettuata da fusebyte 01/09/09 9:10
aaa