Dobrý den, potřebuji poradit. Mám kód:
Imports System
Imports System.Drawing
Imports System.Collections
Imports System.ComponentModel
Imports System.Windows.Forms
Imports System.Data
Imports System.Management
Public Class Form1
Dim prog As String
Private hlidac As ManagementEventWatcher
Dim vypnout As System.Boolean
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If OpenFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
TextBox1.Text = OpenFileDialog1.ShowDialog()
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If CheckBox1.Checked = True Then vypnout = True
hlidac = New ManagementEventWatcher("\\.\root\cimv2", "SELECT * FROM __InstanceCreationEvent WITHIN 1 WHERE TargetInstance ISA 'Win32_Process' AND TargetInstance.Caption = '" & TextBox1.Text & "'")
hlidac.Start()
AddHandler hlidac.EventArrived, AddressOf Me.ZapisRadekDoListBoxu
End Sub
Private Sub ZapisRadekDoListBoxu(ByVal sender As Object, ByVal e As System.Management.EventArrivedEventArgs)
' Je nutne prepnou thread
Me.Invoke(New MethodInvoker(Function() _
ListBox1.Items.Add(DateTime.Now.ToString() & " - Někdo pustil program !!!")))
If vypnout = False Then Exit Sub
Dim mbo As ManagementBaseObject = DirectCast(e.NewEvent("TargetInstance"), ManagementBaseObject)
Dim mp As New ManagementPath(mbo("__PATH").ToString())
Dim pr As New ROOT.CIMV2.Process(mp)
pr.Terminate(1)
End Sub
End Class
který má zjišťovat zapnutí programu. Ale už při kompilaci mi to hlásí chybu: An error occurred creating the form. See Exception.InnerException for details. The error is: Class name does not match. Nevíte co to je?
|