Some stuffs
This commit is contained in:
parent
df3afb30b4
commit
c8496f3baf
|
@ -10,7 +10,7 @@ using System.Drawing;
|
|||
|
||||
namespace CC_Functions.W32
|
||||
{
|
||||
public class KeyboardHookEventArgs : EventArgs
|
||||
public sealed class KeyboardHookEventArgs : EventArgs
|
||||
{
|
||||
public KeyboardHookEventArgs(Keys key)
|
||||
{
|
||||
|
@ -21,7 +21,7 @@ namespace CC_Functions.W32
|
|||
public override string ToString() => Key.ToString();
|
||||
}
|
||||
|
||||
public class KeyboardHook : IDisposable
|
||||
public sealed class KeyboardHook : IDisposable
|
||||
{
|
||||
public void Dispose()
|
||||
{
|
||||
|
|
67
W32/Power.cs
67
W32/Power.cs
|
@ -10,7 +10,7 @@ namespace CC_Functions.W32
|
|||
public static class Power
|
||||
{
|
||||
[DllImport("ntdll.dll", SetLastError = true)]
|
||||
public static extern IntPtr RtlAdjustPrivilege(int Privilege, bool bEnablePrivilege, bool IsThreadPrivilege, out bool PreviousValue);
|
||||
static extern IntPtr RtlAdjustPrivilege(int Privilege, bool bEnablePrivilege, bool IsThreadPrivilege, out bool PreviousValue);
|
||||
[DllImport("ntdll.dll")]
|
||||
private static extern uint NtRaiseHardError(
|
||||
uint ErrorStatus,
|
||||
|
@ -111,69 +111,4 @@ namespace CC_Functions.W32
|
|||
}
|
||||
}
|
||||
}
|
||||
class ugly_copy_paste_code
|
||||
{
|
||||
/*
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
internal struct TokPriv1Luid
|
||||
{
|
||||
public int Count;
|
||||
public long Luid;
|
||||
public int Attr;
|
||||
}
|
||||
|
||||
[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);
|
||||
|
||||
[Flags()]
|
||||
public enum ExitWindowsValues
|
||||
{
|
||||
Logoff = 0x00000000,
|
||||
Shutdown = 0x00000001,
|
||||
Reboot = 0x00000002,
|
||||
Force = 0x00000004,
|
||||
Poweroff = 0x00000008,
|
||||
For
|
||||
}
|
||||
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";
|
||||
internal const int EWX_LOGOFF = 0x00000000;
|
||||
internal const int EWX_SHUTDOWN = 0x00000001;
|
||||
internal const int EWX_REBOOT = 0x00000002;
|
||||
internal const int EWX_FORCE = 0x00000004;
|
||||
internal const int EWX_POWEROFF = 0x00000008;
|
||||
internal const int EWX_FORCEIFHUNG = 0x00000010;
|
||||
|
||||
private void DoExitWin(int flg)
|
||||
{
|
||||
TokPriv1Luid tp;
|
||||
IntPtr hproc = GetCurrentProcess();
|
||||
IntPtr htok = IntPtr.Zero;
|
||||
OpenProcessToken(hproc, TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, ref htok);
|
||||
tp.Count = 1;
|
||||
tp.Luid = 0;
|
||||
tp.Attr = SE_PRIVILEGE_ENABLED;
|
||||
LookupPrivilegeValue(null, SE_SHUTDOWN_NAME, ref tp.Luid);
|
||||
AdjustTokenPrivileges(htok, false, ref tp, 0, IntPtr.Zero, IntPtr.Zero);
|
||||
ExitWindowsEx(flg, 0);
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ using System.Windows.Forms;
|
|||
|
||||
namespace CC_Functions.W32
|
||||
{
|
||||
public class Wnd32 : IEquatable<Wnd32>
|
||||
public sealed class Wnd32 : IEquatable<Wnd32>
|
||||
{
|
||||
#region Exposed
|
||||
#region CreateInstance
|
||||
|
|
Reference in New Issue