Zzz – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | using System; |
2 | using System.Runtime.InteropServices; |
||
3 | |||
4 | namespace Zzz.Action |
||
5 | { |
||
6 | public class ActionHelper |
||
7 | { |
||
8 | #region Static Fields and Constants |
||
9 | |||
10 | public static int WmSysCommand = 0x0112; |
||
11 | |||
12 | public static int ScMonitorPower = 0xF170; |
||
13 | |||
14 | public static int HwndBroadcast = 0xFFFF; |
||
15 | |||
16 | #endregion |
||
17 | |||
18 | #region Public Methods |
||
19 | |||
20 | [DllImport("advapi32.dll")] |
||
21 | public static extern int OpenProcessToken(IntPtr processHandle, |
||
22 | int desiredAccess, out IntPtr tokenHandle); |
||
23 | |||
24 | [DllImport("advapi32.dll", SetLastError = true)] |
||
25 | [return: MarshalAs(UnmanagedType.Bool)] |
||
26 | public static extern bool AdjustTokenPrivileges(IntPtr tokenHandle, |
||
27 | [MarshalAs(UnmanagedType.Bool)] bool disableAllPrivileges, |
||
28 | ref TokenPrivileges newState, |
||
29 | uint bufferLength, |
||
30 | IntPtr previousState, |
||
31 | IntPtr returnLength); |
||
32 | |||
33 | [DllImport("advapi32.dll")] |
||
34 | public static extern int LookupPrivilegeValue(string lpSystemName, |
||
35 | string lpName, out Luid lpLuid); |
||
36 | |||
37 | [DllImport("user32.dll", SetLastError = true)] |
||
38 | public static extern int ExitWindowsEx(uint uFlags, uint dwReason); |
||
39 | |||
40 | [DllImport("Powrprof.dll", CharSet = CharSet.Auto, ExactSpelling = true)] |
||
41 | public static extern bool SetSuspendState(bool hibernate, bool forceCritical, bool disableWakeEvent); |
||
42 | |||
43 | [DllImport("user32.dll", SetLastError = true)] |
||
44 | public static extern bool LockWorkStation(); |
||
45 | |||
46 | [DllImport("user32.dll", CharSet = CharSet.Auto)] |
||
47 | public static extern IntPtr SendMessage(IntPtr hWnd, uint wMsg, UIntPtr wParam, IntPtr lParam); |
||
48 | |||
49 | #endregion |
||
50 | |||
51 | #region Nested Types |
||
52 | |||
53 | public struct Luid |
||
54 | { |
||
55 | public int LowPart; |
||
56 | |||
57 | public int HighPart; |
||
58 | } |
||
59 | |||
60 | public struct LuidAndAttributes |
||
61 | { |
||
62 | public Luid PLuid; |
||
63 | |||
64 | public int Attributes; |
||
65 | } |
||
66 | |||
67 | public struct TokenPrivileges |
||
68 | { |
||
69 | public int PrivilegeCount; |
||
70 | |||
71 | public LuidAndAttributes Privileges; |
||
72 | } |
||
73 | |||
74 | #endregion |
||
75 | } |
||
76 | } |