|
-
Jan 22nd, 2013, 10:20 PM
#1
Thread Starter
Frenzied Member
detect app not responding
Under task manager, if the application freezes, it says not responding. Is there a way or an API that can detect which process name that is not responding?
-
Jan 22nd, 2013, 10:35 PM
#2
Re: detect app not responding
Read this article http://support.microsoft.com/kb/304991, it is use C# but it is simple enough to convert to VB.
-
Jan 23rd, 2013, 02:29 AM
#3
Re: detect app not responding
Not sure if posts #12 and #13 here will be of use or not?
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Jan 23rd, 2013, 02:39 AM
#4
Re: detect app not responding
You could also try the IsHungAppWindow function.
On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)
-
Jan 23rd, 2013, 11:00 AM
#5
Thread Starter
Frenzied Member
Re: detect app not responding
Thanks, all. Is there a way to force the IE to stop responding so that I can test whether or not the code works?
-
Jan 23rd, 2013, 11:06 AM
#6
Re: detect app not responding
You can use SuspendThread.
On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)
-
Jan 23rd, 2013, 11:59 AM
#7
Thread Starter
Frenzied Member
Re: detect app not responding
That is c++, is there a vb one?
-
Jan 23rd, 2013, 12:20 PM
#8
Re: detect app not responding
Here are the VB declares for the abovementioned APIs:
Code:
Private Declare Function IsHungAppWindow Lib "user32.dll" (ByVal hWnd As Long) As Long
Private Declare Function SuspendThread Lib "kernel32.dll" (ByVal hThread As Long) As Long
On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)
-
Jan 24th, 2013, 12:04 PM
#9
Thread Starter
Frenzied Member
Re: detect app not responding
Thanks Bonnie, I'll try that. Does anyone know how to convert this to vb? It's from this site.
http://support.microsoft.com/kb/304991
Code:
procs = Process.GetProcessesByName("IEXPLORE");
-
Jan 24th, 2013, 12:35 PM
#10
Thread Starter
Frenzied Member
Re: detect app not responding
Bonnie, how do I get the thread handle of an application?
-
Jan 24th, 2013, 06:47 PM
#11
Re: detect app not responding
Here is an auto converted of the code at http://support.microsoft.com/kb/304991
Code:
Imports System
Imports System.Drawing
Imports System.Collections
Imports System.ComponentModel
Imports System.Windows.Forms
Imports System.Data
Imports SHDocVw
Imports System.Diagnostics
Namespace appStoppedresponding_cs
Public Class Form1
Inherits System.Windows.Forms.Form
Private WithEvents btnStart As System.Windows.Forms.Button
Private WithEvents btnCheck As System.Windows.Forms.Button
Private WithEvents btnClose As System.Windows.Forms.Button
Private components As System.ComponentModel.Container = Nothing
Private Browser As InternetExplorer
Protected procs() As Process
Public Sub New()
InitializeComponent()
End Sub
Protected Overrides Overloads Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If components IsNot Nothing Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
#Region "Windows Form Designer generated code"
Private Sub InitializeComponent()
Me.btnCheck = New System.Windows.Forms.Button()
Me.btnStart = New System.Windows.Forms.Button()
Me.btnClose = New System.Windows.Forms.Button()
Me.SuspendLayout()
'
' btnCheck
'
Me.btnCheck.Location = New System.Drawing.Point(66, 122)
Me.btnCheck.Name = "btnCheck"
Me.btnCheck.Size = New System.Drawing.Size(152, 23)
Me.btnCheck.TabIndex = 1
Me.btnCheck.Text = "Check Internet Explorer"
' Me.btnCheck.Click += New System.EventHandler(Me.btnCheck_Click)
'
' btnStart
'
Me.btnStart.Location = New System.Drawing.Point(66, 74)
Me.btnStart.Name = "btnStart"
Me.btnStart.Size = New System.Drawing.Size(152, 23)
Me.btnStart.TabIndex = 0
Me.btnStart.Text = "Start Internet Explorer"
' Me.btnStart.Click += New System.EventHandler(Me.btnStart_Click)
'
' btnClose
'
Me.btnClose.Location = New System.Drawing.Point(66, 170)
Me.btnClose.Name = "btnClose"
Me.btnClose.Size = New System.Drawing.Size(152, 23)
Me.btnClose.TabIndex = 2
Me.btnClose.Text = "Close Internet Explorer"
' Me.btnClose.Click += New System.EventHandler(Me.btnClose_Click)
'
' Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 266)
Me.Controls.AddRange(New System.Windows.Forms.Control() { Me.btnClose, Me.btnCheck, Me.btnStart})
Me.Name = "Form1"
Me.Text = "Form1"
' Me.Closing += New System.ComponentModel.CancelEventHandler(Me.Form1_Closing)
' Me.Load += New System.EventHandler(Me.Form1_Load)
Me.ResumeLayout(False)
End Sub
#End Region
'example code
''' The main entry point for the application.
<STAThread>
Shared Sub Main()
Application.Run(New Form1())
End Sub
Private Sub btnStart_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnStart.Click
Browser = New InternetExplorer()
Browser.Visible = True
Browser.GoHome()
procs = Process.GetProcessesByName("IEXPLORE")
'Build event delegate to catch browser close event.
Dim oDelegate As New SHDocVw.DWebBrowserEvents2_OnQuitEventHandler(AddressOf Browser_OnQuit)
Browser.OnQuit += oDelegate
End Sub
Private Sub btnCheck_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCheck.Click
If Browser IsNot Nothing Then
If procs(0).Responding Then
MessageBox.Show("IEXPLORE is Responding")
Else
MessageBox.Show("IEXPLORE is Not Responding")
End If
Else
MessageBox.Show("IEXPLORE is Not Running")
End If
End Sub
Private Sub btnClose_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnClose.Click
Me.closeBrowser()
End Sub
Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
If Browser IsNot Nothing Then
Me.closeBrowser()
End If
End Sub
Private Sub closeBrowser()
Try
If procs(0).Responding Then
procs(0).CloseMainWindow()
Else
procs(0).Kill()
End If
'Destroy object reference and array.
Me.cleanUp()
Catch
MessageBox.Show("Could Not Find the IEXPLORE Process")
End Try
End Sub
Private Sub Browser_OnQuit()
Me.cleanUp()
End Sub
Private Sub cleanUp()
Browser = Nothing
procs=Nothing
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
End Class
End Namespace
-
Jan 24th, 2013, 06:59 PM
#12
Re: detect app not responding
@4x2y,
That is .Net the op wants vb6 code.
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Jan 24th, 2013, 07:21 PM
#13
Re: detect app not responding
 Originally Posted by Nightwalker83
@4x2y,
That is .Net the op wants vb6 code.
Sorry, i misunderstood his question!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|