C#.Net でアプリケーションを作成しようとしています。ユーザーが開始および停止するプロセスをスキャンする必要がありますが、「アクセスが拒否されました」というメッセージが表示されます。.Start()
ここに私がこれまでに持っているものがあります
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using MySql.Data.MySqlClient;
using System.Management;
using Security;
using MySQLConnectivity;
namespace MyApp
{
public partial class Login : Form
{
MySQLClass sql = new MySQLClass();
ManagementEventWatcher processStartEvent = new ManagementEventWatcher("SELECT * FROM Win32_ProcessStartTrace");
ManagementEventWatcher processStopEvent = new ManagementEventWatcher("SELECT * FROM Win32_ProcessStopTrace");
public Login()
{
InitializeComponent();
processStartEvent.EventArrived += new EventArrivedEventHandler(processStartEvent_EventArrived);
processStartEvent.Start();
processStopEvent.EventArrived += new EventArrivedEventHandler(processStopEvent_EventArrived);
processStopEvent.Start();
}
void processStartEvent_EventArrived(object sender, EventArrivedEventArgs e)
{
string processName = e.NewEvent.Properties["ProcessName"].Value.ToString();
string processID = Convert.ToInt32(e.NewEvent.Properties["ProcessID"].Value).ToString();
MessageBox.Show("Process started. Name: " + processName + " | ID: " + processID);
}
void processStopEvent_EventArrived(object sender, EventArrivedEventArgs e)
{
string processName = e.NewEvent.Properties["ProcessName"].Value.ToString();
string processID = Convert.ToInt32(e.NewEvent.Properties["ProcessID"].Value).ToString();
MessageBox.Show("Process stopped. Name: " + processName + " | ID: " + processID);
}
}
}
オンラインで時間を検索しましたが、何も見つかりませんでした。この問題を抱えていた人々は、ローカルではなくリモートで問題を抱えていました。この場合、VSまたはOSのバージョンが重要になる可能性がある場合に備えて、Windows Pro 8.1 + Microsoft Visual Studio Ultimate 2013を使用しています。
processStartEvent.Start()
この問題は、「アクセスが拒否されました」と言ってトリガーされます。私も同じ結果でから.Start()
に切り替えようとしました.WaitForNextEvent()
私がここで見逃しているものはありますか?