• 大小: 0.17M
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2024-04-29
  • 语言: C#
  • 标签: 关机  

资源简介

快速关机

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Shutdown
{
    public partial class Form1 : Form
    {
        private delegate uint ZwShutdownSystem(int ShutdownAction);//编译
        private delegate uint RtlAdjustPrivilege(int Privilege bool Enable bool CurrentThread ref int Enabled);

        [DllImport(“kernel32.dll“)]
        private extern static IntPtr LoadLibrary(String path);
        [DllImport(“kernel32.dll“)]
        private extern static IntPtr GetProcAddress(IntPtr lib String funcName);
        [DllImport(“kernel32.dll“)]
        private extern static bool FreeLibrary(IntPtr lib);

        //将要执行的函数转换为委托
        private static Delegate Invoke(String APIName Type t IntPtr hLib)
        {
            IntPtr api = GetProcAddress(hLib APIName);
            return (Delegate)Marshal.GetDelegateForFunctionPointer(api t);
        }

        public Form1()
        {
            InitializeComponent();
        }
        
        private void button1_Click(object sender EventArgs e)
        {
            IntPtr hLib = LoadLibrary(“ntdll.dll“);
            RtlAdjustPrivilege rtla = (RtlAdjustPrivilege)Invoke(“RtlAdjustPrivilege“ typeof(RtlAdjustPrivilege) hLib);
            ZwShutdownSystem shutdown = (ZwShutdownSystem)Invoke(“ZwShutdownSystem“ typeof(ZwShutdownSystem) hLib);
            
            int en = 0;
            uint ret = rtla(0x13 true false ref en);//SE_SHUTDOWN_PRIVILEGE = 0x13;     //关机权限
            ret = shutdown(2); // POWEROFF = 0x2 // 关机 // REBOOT = 0x1 // 重启
        }
    }
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

    ..A..H.     37376  2020-09-01 14:51  Shutdown\.vs\Shutdown\v15\.suo

     文件          0  2020-09-01 13:40  Shutdown\.vs\Shutdown\v15\Server\sqlite3\db.lock

     文件       4096  2020-09-01 13:40  Shutdown\.vs\Shutdown\v15\Server\sqlite3\storage.ide

     文件      32768  2020-09-01 14:49  Shutdown\.vs\Shutdown\v15\Server\sqlite3\storage.ide-shm

     文件    2657432  2020-09-01 14:50  Shutdown\.vs\Shutdown\v15\Server\sqlite3\storage.ide-wal

     文件        187  2020-09-01 13:40  Shutdown\Shutdown\App.config

     文件       9216  2020-09-01 14:50  Shutdown\Shutdown\bin\Debug\Shutdown.exe

     文件        187  2020-09-01 13:40  Shutdown\Shutdown\bin\Debug\Shutdown.exe.config

     文件      26112  2020-09-01 14:50  Shutdown\Shutdown\bin\Debug\Shutdown.pdb

     文件       1877  2020-09-01 14:50  Shutdown\Shutdown\Form1.cs

     文件       2186  2020-09-01 14:50  Shutdown\Shutdown\Form1.Designer.cs

     文件       5817  2020-09-01 14:50  Shutdown\Shutdown\Form1.resx

     文件       1431  2020-09-01 14:49  Shutdown\Shutdown\obj\Debug\DesignTimeResolveAssemblyReferences.cache

     文件       7060  2020-09-01 13:40  Shutdown\Shutdown\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件         42  2020-09-01 13:40  Shutdown\Shutdown\obj\Debug\Shutdown.csproj.CoreCompileInputs.cache

     文件        625  2020-09-01 13:40  Shutdown\Shutdown\obj\Debug\Shutdown.csproj.FileListAbsolute.txt

     文件       1012  2020-09-01 14:50  Shutdown\Shutdown\obj\Debug\Shutdown.csproj.GenerateResource.cache

     文件      11466  2020-09-01 13:40  Shutdown\Shutdown\obj\Debug\Shutdown.csprojAssemblyReference.cache

     文件       9216  2020-09-01 14:50  Shutdown\Shutdown\obj\Debug\Shutdown.exe

     文件        180  2020-09-01 14:50  Shutdown\Shutdown\obj\Debug\Shutdown.Form1.resources

     文件      26112  2020-09-01 14:50  Shutdown\Shutdown\obj\Debug\Shutdown.pdb

     文件        180  2020-09-01 13:40  Shutdown\Shutdown\obj\Debug\Shutdown.Properties.Resources.resources

     文件          0  2020-09-01 13:40  Shutdown\Shutdown\obj\Debug\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs

     文件          0  2020-09-01 13:40  Shutdown\Shutdown\obj\Debug\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs

     文件          0  2020-09-01 13:40  Shutdown\Shutdown\obj\Debug\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs

     文件        520  2020-09-01 13:40  Shutdown\Shutdown\Program.cs

     文件       1314  2020-09-01 13:40  Shutdown\Shutdown\Properties\AssemblyInfo.cs

     文件       2829  2020-09-01 13:40  Shutdown\Shutdown\Properties\Resources.Designer.cs

     文件       5612  2020-09-01 13:40  Shutdown\Shutdown\Properties\Resources.resx

     文件       1095  2020-09-01 13:40  Shutdown\Shutdown\Properties\Settings.Designer.cs

............此处省略19个文件信息

评论

共有 条评论