Esempio n. 1
0
 private void textBox2_TextChanged(object sender, EventArgs e)
 {
     if (DriverAPIInterface.GetStatus(ServiceName).ToInt32() != 0 && string.Compare(textBox2.Text, ServiceName) != 0)
     {
         if (MessageBox.Show($"当前正在操作【{ServiceName}】驱动,是否取消操作!", "警告", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk) == DialogResult.OK)
         {
             DriverAPIInterface.Close();
         }
         else
         {
         }
         return;
     }
     if (!string.IsNullOrEmpty(ServiceName))
     {
         if (DriverAPIInterface.Open(ServiceName).ToInt32() == 0)
         {
             if (MessageBox.Show($"驱动【{ServiceName}】已存在,是否要操作此驱动?", "警告", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk) == DialogResult.Cancel)
             {
                 DriverAPIInterface.Close();
             }
             RefreshStatus();
         }
     }
 }
Esempio n. 2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            // 在LinkLable控件中可以添加多个链接
            this.linkLabel1.Links.Add(0, this.linkLabel1.Text.Length, @"https://blog.csdn.net/black_bad1993");
            var IsAdmin = DriverAPIInterface.IsRunasAdmin();

            if (IsAdmin)
            {
                this.Text = $"管理员:{this.Text}";
            }
        }
Esempio n. 3
0
 private void button1_Click_1(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(textBox1.Text.Trim()))
     {
         MessageBox.Show("请选择文件!", "选择文件提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     else
     {
         ShowErrorMessage(DriverAPIInterface.Create(ServiceName, DisplayName, textBox1.Text).ToInt32());
         RefreshStatus();
     }
 }
Esempio n. 4
0
 private void button8_Click(object sender, EventArgs e)
 {
     textBox1.Text = AppDomain.CurrentDomain.BaseDirectory + "MyfirstDriver.sys";
     filePath      = textBox1.Text;
     ServiceName   = Path.GetFileNameWithoutExtension(filePath);
     DisplayName   = Path.GetFileNameWithoutExtension(filePath);
     textBox2.Text = ServiceName;
     textBox3.Text = DisplayName;
     DriverAPIInterface.Unload(1000).ToInt32(); //停止驱动
     DriverAPIInterface.Delete().ToInt32();     //卸载驱动
     ShowErrorMessage(DriverAPIInterface.Create(ServiceName, DisplayName, textBox1.Text).ToInt32());
     ShowErrorMessage(DriverAPIInterface.Load().ToInt32());
     RefreshStatus();
 }
Esempio n. 5
0
        private void RefreshStatus()
        {
            bool bCreate = false, bStart = false, bStop = false, bDelete = false;

            switch (dwDriverStatus = DriverAPIInterface.GetStatus(ServiceName).ToInt64())
            {
            case DriverAPIInterface.DRIVER_CLOSED:
                bCreate = true;
                this.Invoke(new Action(() => { label5.Text = "已关闭"; label5.ForeColor = Color.Red; }));
                break;

            case DriverAPIInterface.DRIVER_OPENED:
                bStart  = true;
                bDelete = true;
                this.Invoke(new Action(() => { label5.Text = "已指定驱动"; label5.ForeColor = Color.Blue; }));
                break;

            case DriverAPIInterface.DRIVER_STARTED:
                bStop = true;
                this.Invoke(new Action(() => { label5.Text = "驱动运行中"; label5.ForeColor = Color.Green; }));
                break;

            case DriverAPIInterface.DRIVER_PAUSED:
                bStop = true;
                this.Invoke(new Action(() => { label5.Text = "驱动已被暂停"; label5.ForeColor = Color.Yellow; }));
                break;

            case DriverAPIInterface.DRIVER_BUSY:
                this.Invoke(new Action(() => { label5.Text = "驱动正忙"; label5.ForeColor = Color.RoyalBlue; }));
                break;
            }
            this.Invoke(new Action(() => button1.Enabled = bCreate));
            this.Invoke(new Action(() => button2.Enabled = bStart));
            this.Invoke(new Action(() => button3.Enabled = bStop));
            this.Invoke(new Action(() => button4.Enabled = bDelete));
        }
Esempio n. 6
0
 private void button7_Click(object sender, EventArgs e)
 {
     //C:\HanJunJun\辅助SVN\Code\C++\MyfirstDriver\x64\Debug\MyfirstDriver\MyfirstDriver.sys
     DriverAPIInterface.OperateDriver();
 }
Esempio n. 7
0
 private void button4_Click(object sender, EventArgs e)
 {
     ShowErrorMessage(DriverAPIInterface.Delete().ToInt32());
     RefreshStatus();
 }
Esempio n. 8
0
 private void button3_Click(object sender, EventArgs e)
 {
     ShowErrorMessage(DriverAPIInterface.Unload(1000).ToInt32());
     RefreshStatus();
 }