Note that there are some explanatory texts on larger screens.

plurals
  1. POKill process winword
    primarykey
    data
    text
    <p>To check if a process hangs Word, through a VB.Net 2003 project, I create a thread that makes process control (in question). If after a certain number of milliseconds that the process is still active, I kill the process from the thread. The system tells me "System.ComponentModel.Win32Exception", 'Access Denied'</p> <p>The code is as follows:</p> <p>This is the code Vb:</p> <pre><code>Imports System Imports System.Threading Imports System.Threading.Thread Imports System.Security.Permissions Public Class ThreadMain Public strdotName AsString Public strdocName AsString Public sXML AsString Public idProcesso AsInteger Public terminate AsInteger Public docName AsString Public kk AsInteger Public finito AsBoolean= False Public Function LaunchThread() AsInteger Dim myT2 As Threading.Thread myT2 = New Threading.Thread(AddressOfMe.DoWork) myT2.IsBackground = True myT2.Start() Try Console.WriteLine("Finito: {0}", finito) Catch Ex As Exception End Try Return terminate End Function *-------** Private Sub DoWork() Dim j AsInteger Dim errore AsString Dim trovato AsBoolean Dim colProcess AsProcess Dim nomeProcess AsProcess() Dim chiusura AsBoolean Try For j = 100 To 20000 colProcess = Process.GetProcessById(idProcesso) If Not colProcess IsNothingThen j = j + 1000 System.Threading.Thread.Sleep(1) trovato = True Else trovato = False End If Next If trovato Then chiusura = colProcess.CloseMainWindow() colProcess.Close() Process.GetProcessById(idProcesso).Kill() terminate = 1 End If Catch ex As Exception errore = ex.ToString terminate = 2 End Try End Sub 'DoWork </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload