问答文章1 问答文章501 问答文章1001 问答文章1501 问答文章2001 问答文章2501 问答文章3001 问答文章3501 问答文章4001 问答文章4501 问答文章5001 问答文章5501 问答文章6001 问答文章6501 问答文章7001 问答文章7501 问答文章8001 问答文章8501 问答文章9001 问答文章9501

c# 使用Forms.Message类型或者调用API的方法

发布网友 发布时间:2022-04-24 01:57

我来回答

2个回答

热心网友 时间:2023-10-20 09:16

using System.Text;

using Microsoft.Win32;
using System.Runtime.InteropServices;
using System.Threading;

namespace iSchoolWebBrowser
{
class EnvironmentCheckClass
{

[DllImport("user32.dll")]
static extern bool ExitWindowsEx(ExitWindows uFlags, ShutdownReason dwReason);
[DllImport("kernel32.dll", ExactSpelling = true)]
internal static extern IntPtr GetCurrentProcess();

[DllImport("advapi32.dll", ExactSpelling = true, SetLastError = true)]
internal static extern bool OpenProcessToken(IntPtr h, int acc, ref IntPtr phtok);

[DllImport("advapi32.dll", SetLastError = true)]
internal static extern bool LookupPrivilegeValue(string host, string name, ref long pluid);

[DllImport("advapi32.dll", ExactSpelling = true, SetLastError = true)]
internal static extern bool AdjustTokenPrivileges(IntPtr htok, bool disall,
ref TokPriv1Luid newst, int len, IntPtr prev, IntPtr relen);

[DllImport("user32.dll", ExactSpelling = true, SetLastError = true)]
internal static extern bool ExitWindowsEx(int flg, int rea);

[StructLayout(LayoutKind.Sequential, Pack = 1)]
internal struct TokPriv1Luid
{
public int Count;
public long Luid;
public int Attr;
}

internal const int SE_PRIVILEGE_ENABLED = 0x00000002;
internal const int TOKEN_QUERY = 0x00000008;
internal const int TOKEN_ADJUST_PRIVILEGES = 0x00000020;
internal const string SE_SHUTDOWN_NAME = "SeShutdownPrivilege";

public enum ExitWindows : uint
{
LogOff = 0x00, //注销
ShutDown = 0x01, //关机
Reboot = 0x00000002, //重启
Force = 0x04,
PowerOff = 0x08,
ForceIfHung = 0x10
}
public enum ShutdownReason : uint
{
MajorApplication = 0x00040000,
MajorHardware = 0x00010000,
MajorLegacyApi = 0x00070000,
MajorOperatingSystem = 0x00020000,
MajorOther = 0x00000000,
MajorPower = 0x00060000,
MajorSoftware = 0x00030000,
MajorSystem = 0x00050000,

MinorBlueScreen = 0x0000000F,
MinorCordUnplugged = 0x0000000b,
MinorDisk = 0x00000007,
MinorEnvironment = 0x0000000c,
MinorHardwareDriver = 0x0000000d,
MinorHotfix = 0x00000011,
MinorHung = 0x00000005,
MinorInstallation = 0x00000002,
MinorMaintenance = 0x00000001,
MinorMMC = 0x00000019,
MinorNetworkConnectivity = 0x00000014,
MinorNetworkCard = 0x00000009,
MinorOther = 0x00000000,
MinorOtherDriver = 0x0000000e,
MinorPowerSupply = 0x0000000a,
MinorProcessor = 0x00000008,
MinorReconfig = 0x00000004,
MinorSecurity = 0x00000013,
MinorSecurityFix = 0x00000012,
MinorSecurityFixUninstall = 0x00000018,
MinorServicePack = 0x00000010,
MinorServicePackUninstall = 0x00000016,
MinorTermSrv = 0x00000020,
MinorUnstable = 0x00000006,
MinorUpgrade = 0x00000003,
MinorWMI = 0x00000015,

FlagUserDefined = 0x40000000,
FlagPlanned = 0x80000000
}

const string keys = "JAVA_PLUGIN_WEBCONTROL_ENABLE";

public bool InitEPath()
{
RegistryKey pregkey;

try
{
pregkey = Registry.LocalMachine.OpenSubKey("SYSTEM", true).OpenSubKey("ControlSet001", true).OpenSubKey("Control", true).OpenSubKey("Session Manager", true).OpenSubKey("Environment", true);

if (null != pregkey)
{
if (null == pregkey.GetValue(keys))
{
pregkey.SetValue(keys, "TRUE");
pregkey.Close();
return true;
}
}
}
catch
{

}
return false;
}
public void ReStartComputer()
{
System.Threading.Thread Restart = new Thread(ReSart);
Restart.Start();
}
private void ReSart()
{
try
{
System.Threading.Thread.Sleep(1000);
//2
bool ok;
TokPriv1Luid tp;
IntPtr hproc = GetCurrentProcess();
IntPtr htok = IntPtr.Zero;
ok = OpenProcessToken(hproc, TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, ref htok);
tp.Count = 1;
tp.Luid = 0;
tp.Attr = SE_PRIVILEGE_ENABLED;
ok = LookupPrivilegeValue(null, SE_SHUTDOWN_NAME, ref tp.Luid);
ok = AdjustTokenPrivileges(htok, false, ref tp, 0, IntPtr.Zero, IntPtr.Zero);
ok = ExitWindowsEx(ExitWindows.Reboot, ShutdownReason.MinorOther);
}
catch
{ }
}

}
}

热心网友 时间:2023-10-20 09:16

先看看这个地址:

http://www.czvec.com/jt/main/output.asp?haxz2=358

留个联系方式

我给你发一个win32文档!里面有很全的api讲解!

文档已经发送!!!!

热心网友 时间:2023-10-20 09:16

using System.Text;

using Microsoft.Win32;
using System.Runtime.InteropServices;
using System.Threading;

namespace iSchoolWebBrowser
{
class EnvironmentCheckClass
{

[DllImport("user32.dll")]
static extern bool ExitWindowsEx(ExitWindows uFlags, ShutdownReason dwReason);
[DllImport("kernel32.dll", ExactSpelling = true)]
internal static extern IntPtr GetCurrentProcess();

[DllImport("advapi32.dll", ExactSpelling = true, SetLastError = true)]
internal static extern bool OpenProcessToken(IntPtr h, int acc, ref IntPtr phtok);

[DllImport("advapi32.dll", SetLastError = true)]
internal static extern bool LookupPrivilegeValue(string host, string name, ref long pluid);

[DllImport("advapi32.dll", ExactSpelling = true, SetLastError = true)]
internal static extern bool AdjustTokenPrivileges(IntPtr htok, bool disall,
ref TokPriv1Luid newst, int len, IntPtr prev, IntPtr relen);

[DllImport("user32.dll", ExactSpelling = true, SetLastError = true)]
internal static extern bool ExitWindowsEx(int flg, int rea);

[StructLayout(LayoutKind.Sequential, Pack = 1)]
internal struct TokPriv1Luid
{
public int Count;
public long Luid;
public int Attr;
}

internal const int SE_PRIVILEGE_ENABLED = 0x00000002;
internal const int TOKEN_QUERY = 0x00000008;
internal const int TOKEN_ADJUST_PRIVILEGES = 0x00000020;
internal const string SE_SHUTDOWN_NAME = "SeShutdownPrivilege";

public enum ExitWindows : uint
{
LogOff = 0x00, //注销
ShutDown = 0x01, //关机
Reboot = 0x00000002, //重启
Force = 0x04,
PowerOff = 0x08,
ForceIfHung = 0x10
}
public enum ShutdownReason : uint
{
MajorApplication = 0x00040000,
MajorHardware = 0x00010000,
MajorLegacyApi = 0x00070000,
MajorOperatingSystem = 0x00020000,
MajorOther = 0x00000000,
MajorPower = 0x00060000,
MajorSoftware = 0x00030000,
MajorSystem = 0x00050000,

MinorBlueScreen = 0x0000000F,
MinorCordUnplugged = 0x0000000b,
MinorDisk = 0x00000007,
MinorEnvironment = 0x0000000c,
MinorHardwareDriver = 0x0000000d,
MinorHotfix = 0x00000011,
MinorHung = 0x00000005,
MinorInstallation = 0x00000002,
MinorMaintenance = 0x00000001,
MinorMMC = 0x00000019,
MinorNetworkConnectivity = 0x00000014,
MinorNetworkCard = 0x00000009,
MinorOther = 0x00000000,
MinorOtherDriver = 0x0000000e,
MinorPowerSupply = 0x0000000a,
MinorProcessor = 0x00000008,
MinorReconfig = 0x00000004,
MinorSecurity = 0x00000013,
MinorSecurityFix = 0x00000012,
MinorSecurityFixUninstall = 0x00000018,
MinorServicePack = 0x00000010,
MinorServicePackUninstall = 0x00000016,
MinorTermSrv = 0x00000020,
MinorUnstable = 0x00000006,
MinorUpgrade = 0x00000003,
MinorWMI = 0x00000015,

FlagUserDefined = 0x40000000,
FlagPlanned = 0x80000000
}

const string keys = "JAVA_PLUGIN_WEBCONTROL_ENABLE";

public bool InitEPath()
{
RegistryKey pregkey;

try
{
pregkey = Registry.LocalMachine.OpenSubKey("SYSTEM", true).OpenSubKey("ControlSet001", true).OpenSubKey("Control", true).OpenSubKey("Session Manager", true).OpenSubKey("Environment", true);

if (null != pregkey)
{
if (null == pregkey.GetValue(keys))
{
pregkey.SetValue(keys, "TRUE");
pregkey.Close();
return true;
}
}
}
catch
{

}
return false;
}
public void ReStartComputer()
{
System.Threading.Thread Restart = new Thread(ReSart);
Restart.Start();
}
private void ReSart()
{
try
{
System.Threading.Thread.Sleep(1000);
//2
bool ok;
TokPriv1Luid tp;
IntPtr hproc = GetCurrentProcess();
IntPtr htok = IntPtr.Zero;
ok = OpenProcessToken(hproc, TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, ref htok);
tp.Count = 1;
tp.Luid = 0;
tp.Attr = SE_PRIVILEGE_ENABLED;
ok = LookupPrivilegeValue(null, SE_SHUTDOWN_NAME, ref tp.Luid);
ok = AdjustTokenPrivileges(htok, false, ref tp, 0, IntPtr.Zero, IntPtr.Zero);
ok = ExitWindowsEx(ExitWindows.Reboot, ShutdownReason.MinorOther);
}
catch
{ }
}

}
}

热心网友 时间:2023-10-20 09:16

先看看这个地址:

http://www.czvec.com/jt/main/output.asp?haxz2=358

留个联系方式

我给你发一个win32文档!里面有很全的api讲解!

文档已经发送!!!!

热心网友 时间:2023-10-20 09:15

using System.Text;

using Microsoft.Win32;
using System.Runtime.InteropServices;
using System.Threading;

namespace iSchoolWebBrowser
{
class EnvironmentCheckClass
{

[DllImport("user32.dll")]
static extern bool ExitWindowsEx(ExitWindows uFlags, ShutdownReason dwReason);
[DllImport("kernel32.dll", ExactSpelling = true)]
internal static extern IntPtr GetCurrentProcess();

[DllImport("advapi32.dll", ExactSpelling = true, SetLastError = true)]
internal static extern bool OpenProcessToken(IntPtr h, int acc, ref IntPtr phtok);

[DllImport("advapi32.dll", SetLastError = true)]
internal static extern bool LookupPrivilegeValue(string host, string name, ref long pluid);

[DllImport("advapi32.dll", ExactSpelling = true, SetLastError = true)]
internal static extern bool AdjustTokenPrivileges(IntPtr htok, bool disall,
ref TokPriv1Luid newst, int len, IntPtr prev, IntPtr relen);

[DllImport("user32.dll", ExactSpelling = true, SetLastError = true)]
internal static extern bool ExitWindowsEx(int flg, int rea);

[StructLayout(LayoutKind.Sequential, Pack = 1)]
internal struct TokPriv1Luid
{
public int Count;
public long Luid;
public int Attr;
}

internal const int SE_PRIVILEGE_ENABLED = 0x00000002;
internal const int TOKEN_QUERY = 0x00000008;
internal const int TOKEN_ADJUST_PRIVILEGES = 0x00000020;
internal const string SE_SHUTDOWN_NAME = "SeShutdownPrivilege";

public enum ExitWindows : uint
{
LogOff = 0x00, //注销
ShutDown = 0x01, //关机
Reboot = 0x00000002, //重启
Force = 0x04,
PowerOff = 0x08,
ForceIfHung = 0x10
}
public enum ShutdownReason : uint
{
MajorApplication = 0x00040000,
MajorHardware = 0x00010000,
MajorLegacyApi = 0x00070000,
MajorOperatingSystem = 0x00020000,
MajorOther = 0x00000000,
MajorPower = 0x00060000,
MajorSoftware = 0x00030000,
MajorSystem = 0x00050000,

MinorBlueScreen = 0x0000000F,
MinorCordUnplugged = 0x0000000b,
MinorDisk = 0x00000007,
MinorEnvironment = 0x0000000c,
MinorHardwareDriver = 0x0000000d,
MinorHotfix = 0x00000011,
MinorHung = 0x00000005,
MinorInstallation = 0x00000002,
MinorMaintenance = 0x00000001,
MinorMMC = 0x00000019,
MinorNetworkConnectivity = 0x00000014,
MinorNetworkCard = 0x00000009,
MinorOther = 0x00000000,
MinorOtherDriver = 0x0000000e,
MinorPowerSupply = 0x0000000a,
MinorProcessor = 0x00000008,
MinorReconfig = 0x00000004,
MinorSecurity = 0x00000013,
MinorSecurityFix = 0x00000012,
MinorSecurityFixUninstall = 0x00000018,
MinorServicePack = 0x00000010,
MinorServicePackUninstall = 0x00000016,
MinorTermSrv = 0x00000020,
MinorUnstable = 0x00000006,
MinorUpgrade = 0x00000003,
MinorWMI = 0x00000015,

FlagUserDefined = 0x40000000,
FlagPlanned = 0x80000000
}

const string keys = "JAVA_PLUGIN_WEBCONTROL_ENABLE";

public bool InitEPath()
{
RegistryKey pregkey;

try
{
pregkey = Registry.LocalMachine.OpenSubKey("SYSTEM", true).OpenSubKey("ControlSet001", true).OpenSubKey("Control", true).OpenSubKey("Session Manager", true).OpenSubKey("Environment", true);

if (null != pregkey)
{
if (null == pregkey.GetValue(keys))
{
pregkey.SetValue(keys, "TRUE");
pregkey.Close();
return true;
}
}
}
catch
{

}
return false;
}
public void ReStartComputer()
{
System.Threading.Thread Restart = new Thread(ReSart);
Restart.Start();
}
private void ReSart()
{
try
{
System.Threading.Thread.Sleep(1000);
//2
bool ok;
TokPriv1Luid tp;
IntPtr hproc = GetCurrentProcess();
IntPtr htok = IntPtr.Zero;
ok = OpenProcessToken(hproc, TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, ref htok);
tp.Count = 1;
tp.Luid = 0;
tp.Attr = SE_PRIVILEGE_ENABLED;
ok = LookupPrivilegeValue(null, SE_SHUTDOWN_NAME, ref tp.Luid);
ok = AdjustTokenPrivileges(htok, false, ref tp, 0, IntPtr.Zero, IntPtr.Zero);
ok = ExitWindowsEx(ExitWindows.Reboot, ShutdownReason.MinorOther);
}
catch
{ }
}

}
}

热心网友 时间:2023-10-20 09:16

先看看这个地址:

http://www.czvec.com/jt/main/output.asp?haxz2=358

留个联系方式

我给你发一个win32文档!里面有很全的api讲解!

文档已经发送!!!!
声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com
whether...ornot必须搭配着用么? whether必须跟or not吗 z97主板与b85有什么区别? b85主板和z97的区别有哪些 z97和b85有什么区别? shuxpai锁了屏怎么办? AI软件在保存文件时,出现"0x01d93ff0"指令引用的“0x00000000”内存。该... AI文件保存时保存不了。无法以此文件名存储。请以其它名称或在其它文... 上海买衣服最实惠的地方再哪 在上海买衣服去哪好呢? vb游戏修改器(没分了,大侠) php怎么获取钉钉员工授权信息? c++问题求解 幼教毕业论文怎么写啊 《RS江湖》Runescape怎么玩如何赚钱? 根据幼教专业,写一篇关于理想的论文!1500字! 词法扫描器 c c++ Polo plus得到过什么奖项? 我为什么要做幼儿教师500字左右的论文 数码宝贝 装甲进化 罗马音 求一篇3000字左右的幼师毕业论文 ~~!急求~~! 2.4g和5g要不要合并?对生活有什么影响么? 求幼师论文3000字不低于10篇文献 求计算机休眠代码 如何做一名幼儿教师论文 如何做一名优秀的幼儿园教师论文 好多电脑专业术语(指英文的),特别是一些英文大写字母缩写,在哪里有专门... 五香卤豆干的做法步骤图,五香卤豆干怎么做 病毒是怎么让杀毒软件无法启动的? 卤水煮豆干的做法,卤水煮豆干怎么做好吃,卤水 java 关于file reading and token 绍兴的房子可以在萧山的银行做房子抵押贷款吗?有区域限制吗 萧山典当行房贷利息是几离? 小伙背30年房贷去相亲被嫌弃,30年房贷的压力有多大? 小伙背着月供8700元的30年房贷相亲,姑娘被吓跑,你能接受高房贷吗? 带三十年房贷相亲被骂小伙发声:“我还得起,我买房没错”,他真的没错吗? 手机设置字体 步步高音乐手机,滑盖的有哪些?还有它们的简单介绍? 步步高音乐手机有哪几款是滑盖的? 步步高i188滑盖手机内存多大?功能怎么样? 步步高音乐手机刚出的那款滑盖手机怎么样 详细资料 步步高的滑盖手机有哪些 请问各位,步步高的哪款手机是滑盖的,实用的,价格不超过850的,跪求…重金 步步高滑盖手机 步步高那款是滑盖的? 步步高1500左右的滑盖手机型号 推荐几款滑盖手机 LG 步步高....等等的都可以 音乐功能要强 1000元左右吧 步步高i270滑盖的手机怎么样?好用吗?功能怎么样?齐全吗? 步步高白色滑盖手机 步步高滑盖音乐手机i188是 智能机 吗