本文介绍了我的程序已停止响应WMI事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
让我告诉你我的问题...
我已经编写了一个可以响应WMI事件的程序
我运行它,每件事都很酷... :)
但是后来,当我尝试时,尽管事件已发生,但我的程序仍停止响应该事件
而且我从未对代码进行任何修改...
你能帮我吗?...请:sigh:
这是我的代码,从"A"到"Z" :(我向项目添加了System.management引用)
Let me tell you about my problem...
I have made a program that react with WMI Events
I run it and every thing work cool... :)
but later, when I try it ,my program stopped to react with the event although the Event has occured
and I never made any modification to the code...
can you help me....please :sigh:
this is my code from ''A'' to ''Z'' :(I have Added System.management refrence to my project)
Imports System.Management
Public Class Form1
Dim WithEvents watcher As New ManagementEventWatcher("Select * from Win32_ComputerShutdownEvent Within 1")
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
watcher.Stop()
watcher.Dispose()
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
watcher.Start()
End Sub
Private Sub watcher_EventArrived(ByVal sender As Object, ByVal e As System.Management.EventArrivedEventArgs) Handles watcher.EventArrived
MessageBox.Show("Good buy")
End Sub
End Class
我的操作系统:Windows Xp SP3
my os: Windows Xp SP3
推荐答案
这篇关于我的程序已停止响应WMI事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!