Zzz – Rev 1

Subversion Repositories:
Rev:
using System;
using System.Runtime.InteropServices;

namespace Zzz.Action
{
    public class ActionHelper
    {
        #region Static Fields and Constants

        public static int WmSysCommand = 0x0112;

        public static int ScMonitorPower = 0xF170;

        public static int HwndBroadcast = 0xFFFF;

        #endregion

        #region Public Methods

        [DllImport("advapi32.dll")]
        public static extern int OpenProcessToken(IntPtr processHandle,
                                                  int desiredAccess, out IntPtr tokenHandle);

        [DllImport("advapi32.dll", SetLastError = true)]
        [return: MarshalAs(UnmanagedType.Bool)]
        public static extern bool AdjustTokenPrivileges(IntPtr tokenHandle,
                                                        [MarshalAs(UnmanagedType.Bool)] bool disableAllPrivileges,
                                                        ref TokenPrivileges newState,
                                                        uint bufferLength,
                                                        IntPtr previousState,
                                                        IntPtr returnLength);

        [DllImport("advapi32.dll")]
        public static extern int LookupPrivilegeValue(string lpSystemName,
                                                      string lpName, out Luid lpLuid);

        [DllImport("user32.dll", SetLastError = true)]
        public static extern int ExitWindowsEx(uint uFlags, uint dwReason);

        [DllImport("Powrprof.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
        public static extern bool SetSuspendState(bool hibernate, bool forceCritical, bool disableWakeEvent);

        [DllImport("user32.dll", SetLastError = true)]
        public static extern bool LockWorkStation();

        [DllImport("user32.dll", CharSet = CharSet.Auto)]
        public static extern IntPtr SendMessage(IntPtr hWnd, uint wMsg, UIntPtr wParam, IntPtr lParam);

        #endregion

        #region Nested Types

        public struct Luid
        {
            public int LowPart;

            public int HighPart;
        }

        public struct LuidAndAttributes
        {
            public Luid PLuid;

            public int Attributes;
        }

        public struct TokenPrivileges
        {
            public int PrivilegeCount;

            public LuidAndAttributes Privileges;
        }

        #endregion
    }
}

Generated by GNU Enscript 1.6.5.90.