At last we can output stuff on our display.
authorStephaneLenclud
Sat, 09 Feb 2013 17:18:09 +0100
changeset 39460a1e2b6ed71
parent 393 4e41fb513d52
child 395 df649224ba4d
At last we can output stuff on our display.
The whole thing is still quite broken though.
GUI/MainForm.cs
GUI/SoundGraphDisplay.cs
GUI/SoundGraphServer.cs
OpenHardwareMonitor.csproj
OpenHardwareMonitor.sln
OpenHardwareMonitorLib.csproj
UacHelpers.CppLibrary/AssemblyInfo.cpp
UacHelpers.CppLibrary/UacHelpers.CppLibrary.vcproj
UacHelpers.CppLibrary/UacHelpers.CppLibrary.vcxproj
UacHelpers.CppLibrary/UserAccountControl.cpp
UacHelpers.CppLibrary/UserAccountControl.h
     1.1 --- a/GUI/MainForm.cs	Mon Feb 04 00:47:01 2013 +0100
     1.2 +++ b/GUI/MainForm.cs	Sat Feb 09 17:18:09 2013 +0100
     1.3 @@ -39,6 +39,7 @@
     1.4      private Color[] plotColorPalette;
     1.5      private SystemTray systemTray;
     1.6      private SoundGraphDisplay soundGraphDisplay;
     1.7 +    private bool displayTick;
     1.8      private StartupManager startupManager = new StartupManager();
     1.9      private UpdateVisitor updateVisitor = new UpdateVisitor();
    1.10      private SensorGadget gadget;
    1.11 @@ -285,18 +286,9 @@
    1.12  
    1.13        InitializePlotForm();
    1.14  
    1.15 -      //
    1.16 -      if (soundGraphDisplay.IsDllLoaded)
    1.17 -      {
    1.18 -          //Try init
    1.19 -          //NativeWindow window;
    1.20 -          soundGraphDisplay.Init(Handle);
    1.21  
    1.22 -          //= Window.GetWindow(this);
    1.23 -          //var wih = new WindowInteropHelper(window);
    1.24 -          //IntPtr hWnd = wih.Handle;
    1.25 -      }
    1.26 -      
    1.27 +      soundGraphDisplay.Init();
    1.28 +
    1.29  
    1.30  
    1.31        startupMenuItem.Visible = startupManager.IsAvailable;
    1.32 @@ -523,6 +515,20 @@
    1.33  
    1.34        if (wmiProvider != null)
    1.35          wmiProvider.Update();
    1.36 +
    1.37 +      if (soundGraphDisplay != null)
    1.38 +      {
    1.39 +          displayTick=!displayTick;
    1.40 +          if (displayTick)
    1.41 +          {
    1.42 +              soundGraphDisplay.SetText("       ---", "");
    1.43 +          }
    1.44 +          else
    1.45 +          {
    1.46 +              soundGraphDisplay.SetText("       -+-", "");
    1.47 +          }
    1.48 +      }  
    1.49 +
    1.50      }
    1.51  
    1.52      private void SaveConfiguration() {
    1.53 @@ -738,41 +744,8 @@
    1.54        const int SC_MINIMIZE = 0xF020;
    1.55        const int SC_CLOSE = 0xF060;
    1.56  
    1.57 -      if (m.Msg == SoundGraph.WM_DSP_PLUGIN_NOTIFY)
    1.58 -      {
    1.59 -        //Handling messages from our iMON Display
    1.60 -          switch ((SoundGraph.DSPNotifyCode)m.WParam.ToInt32())
    1.61 -          {
    1.62 -              case SoundGraph.DSPNotifyCode.DSPNM_PLUGIN_SUCCEED:
    1.63 -              case SoundGraph.DSPNotifyCode.DSPNM_IMON_RESTARTED:
    1.64 -              case SoundGraph.DSPNotifyCode.DSPNM_HW_CONNECTED:
    1.65 -                  {
    1.66 -                      //Connection with our display is now open
    1.67 -                      //Check if we have LCD or VFD
    1.68 -                      //if ((lParam & DSPN_DSP_VFD) == DSPN_DSP_VFD) m_bVfdConnected = TRUE;
    1.69 -                      //if ((lParam & DSPN_DSP_LCD) == DSPN_DSP_LCD) m_bLcdConnected = TRUE;
    1.70 -                      soundGraphDisplay.DisplayPluginMessage(m.WParam.ToInt32(),false);
    1.71 -                  }
    1.72 -                  break;
    1.73 -
    1.74 -              case SoundGraph.DSPNotifyCode.DSPNM_PLUGIN_FAILED:
    1.75 -              case SoundGraph.DSPNotifyCode.DSPNM_HW_DISCONNECTED:
    1.76 -              case SoundGraph.DSPNotifyCode.DSPNM_IMON_CLOSED:
    1.77 -                  {
    1.78 -                      //Connection with our display is closed
    1.79 -                      soundGraphDisplay.DisplayPluginMessage(m.LParam.ToInt32(), true);
    1.80 -                  }
    1.81 -                  break;
    1.82 -
    1.83 -              case SoundGraph.DSPNotifyCode.DSPNM_LCD_TEXT_SCROLL_DONE:
    1.84 -                  {
    1.85 -                      //Scroll finnished
    1.86 -                  }
    1.87 -                  break;
    1.88 -          }
    1.89 -
    1.90 -      }
    1.91 -      else if (minimizeToTray.Value &&
    1.92 + 
    1.93 +      if (minimizeToTray.Value &&
    1.94          m.Msg == WM_SYSCOMMAND && m.WParam.ToInt64() == SC_MINIMIZE)
    1.95        {
    1.96            SysTrayHideShow();
     2.1 --- a/GUI/SoundGraphDisplay.cs	Mon Feb 04 00:47:01 2013 +0100
     2.2 +++ b/GUI/SoundGraphDisplay.cs	Sat Feb 09 17:18:09 2013 +0100
     2.3 @@ -12,164 +12,18 @@
     2.4  using System.Collections.Generic;
     2.5  using System.Drawing;
     2.6  using System.Text;
     2.7 +using System.Diagnostics;
     2.8  using System.Windows.Forms;
     2.9  using System.Windows;
    2.10  using OpenHardwareMonitor.Hardware;
    2.11  using OpenHardwareMonitor.Utilities;
    2.12  using System.Runtime.InteropServices;
    2.13 +using UacHelpers;
    2.14  
    2.15  
    2.16  
    2.17 -static class NativeMethods
    2.18 -{
    2.19 -    [System.Flags]
    2.20 -    public enum LoadLibraryFlags : uint
    2.21 -    {
    2.22 -        DONT_RESOLVE_DLL_REFERENCES = 0x00000001,
    2.23 -        LOAD_IGNORE_CODE_AUTHZ_LEVEL = 0x00000010,
    2.24 -        LOAD_LIBRARY_AS_DATAFILE = 0x00000002,
    2.25 -        LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE = 0x00000040,
    2.26 -        LOAD_LIBRARY_AS_IMAGE_RESOURCE = 0x00000020,
    2.27 -        LOAD_WITH_ALTERED_SEARCH_PATH = 0x00000008
    2.28 -    }
    2.29  
    2.30  
    2.31 -    [DllImport("kernel32.dll", SetLastError = true)]
    2.32 -    public static extern IntPtr LoadLibrary(string dllToLoad);
    2.33 -
    2.34 -    [DllImport("kernel32.dll")]
    2.35 -    public static extern IntPtr LoadLibraryEx(string lpFileName, IntPtr hReservedNull, LoadLibraryFlags dwFlags);
    2.36 -
    2.37 -    [DllImport("kernel32.dll", SetLastError = true)]
    2.38 -    public static extern IntPtr GetProcAddress(IntPtr hModule, string procedureName);
    2.39 -
    2.40 -    [DllImport("kernel32.dll", SetLastError = true)]
    2.41 -    public static extern bool FreeLibrary(IntPtr hModule);
    2.42 -}
    2.43 -
    2.44 -/**
    2.45 -Definitions taken from public Sound Graph APIs.
    2.46 - */
    2.47 -static class SoundGraph
    2.48 -{
    2.49 -
    2.50 -    const int WM_APP = 0x8000;
    2.51 -    public const int WM_DSP_PLUGIN_NOTIFY = WM_APP + 1121;
    2.52 -    /**DSPResult
    2.53 -    @brief	These enumeration values represent the returned result for iMON Display API function calls.\n
    2.54 -			    All iMON Display API function calls return one of this result values.\n
    2.55 -			    For meaning of each result, refer the comment of each line below*/
    2.56 -    public enum DSPResult : int
    2.57 -    {
    2.58 -	    DSP_SUCCEEDED = 0,				//// Function Call Succeeded Without Error
    2.59 -	    DSP_E_FAIL,						//// Unspecified Failure
    2.60 -	    DSP_E_OUTOFMEMORY,				//// Failed to Allocate Necessary Memory
    2.61 -	    DSP_E_INVALIDARG,				//// One or More Arguments Are Not Valid
    2.62 -	    DSP_E_NOT_INITED,				//// API is Not Initialized
    2.63 -	    DSP_E_POINTER,					//// Pointer is Not Valid
    2.64 -
    2.65 -	    DSP_S_INITED = 0x1000,			//// API is Initialized
    2.66 -	    DSP_S_NOT_INITED,				//// API is Not Initialized
    2.67 -	    DSP_S_IN_PLUGIN_MODE,			//// API Can Control iMON Display (Display Plug-in Mode)
    2.68 -	    DSP_S_NOT_IN_PLUGIN_MODE,		//// API Can't Control iMON Display
    2.69 -    };
    2.70 -
    2.71 -
    2.72 -    /**DSPNInitResult
    2.73 -    @brief	These enumeration values represent the result status for requesting Display Plug-in Mode to iMON.\n
    2.74 -			    iMON Display API notifies one of this result values to the caller application after requesting Display Plug-in Mode to iMON.\n
    2.75 -			    For more information, refer the comment of each line below*/
    2.76 -    public enum DSPNInitResult : int
    2.77 -    {
    2.78 -	    DSPN_SUCCEEDED = 0,				//// Display Plug-in Mode is Initialized Successfully
    2.79 -	    DSPN_ERR_IN_USED = 0x0100,		//// Display Plug-in is Already Used by Other Application
    2.80 -	    DSPN_ERR_HW_DISCONNECTED,		//// iMON HW is Not Connected
    2.81 -	    DSPN_ERR_NOT_SUPPORTED_HW,		//// The Connected iMON HW doesn't Support Display Plug-in
    2.82 -	    DSPN_ERR_PLUGIN_DISABLED,		//// Display Plug-in Mode Option is Disabled
    2.83 -	    DSPN_ERR_IMON_NO_REPLY,			//// The Latest iMON is Not Installed or iMON Not Running
    2.84 -	    DSPN_ERR_UNKNOWN = 0x0200,		//// Unknown Failure
    2.85 -    };
    2.86 -
    2.87 -
    2.88 -    /**DSPType
    2.89 -    @brief	These enumeration values represent display type.\n
    2.90 -			    Currently iMON Display API supports VFD and LCD products.*/
    2.91 -    public enum DSPType : int
    2.92 -    {
    2.93 -	    DSPN_DSP_NONE	= 0,
    2.94 -	    DSPN_DSP_VFD	= 0x01,			//// VFD products
    2.95 -	    DSPN_DSP_LCD	= 0x02,			//// LCD products
    2.96 -    };
    2.97 -
    2.98 -
    2.99 -    /**DSPNotifyCode
   2.100 -    @brief	These enumeration values represent the notification codes.\n
   2.101 -			    iMON Display API will send or post message to the caller application.\n
   2.102 -			    The caller application should assign the message and the winodw handle to receivce message with IMON_Display_Init fucntion.\n
   2.103 -			    These enumeration values are used with WPARAM parameter of the message.\n 
   2.104 -			    For more information, see the explanation of each notification code below*/
   2.105 -    public enum DSPNotifyCode : int
   2.106 -    {
   2.107 -	    /**DSPNM_PLUGIN_SUCCEED
   2.108 -	    @brief	When API succeeds to get the control for the display, API will post caller-specified message with DSPNM_PLUGIN_SUCCEED as WPARAM parameter.\n
   2.109 -				    LPARAM represents DSPType. This value can be 0x01 (VFD), 0x02 (LCD) or 0x03 (VFD+LCD).*/
   2.110 -	    DSPNM_PLUGIN_SUCCEED = 0,
   2.111 -
   2.112 -	    /**DSPNM_PLUGIN_FAILED
   2.113 -	    @brief	When API fails to get the control for the display, API will post caller-specified message with DSPNM_PLUGIN_FAILED as WPARAM parameter.\n
   2.114 -				    LPARAM represents error code with DSPNResult.*/
   2.115 -	    DSPNM_PLUGIN_FAILED,
   2.116 -
   2.117 -	    /**DSPNM_IMON_RESTARTED
   2.118 -	    @brief	When iMON starts, API will post caller-specified message with DSPNM_IMON_RESTARTED as WPARAM parameter.\n
   2.119 -				    LPARAM represents DSPType. This value can be 0 (No Display), 0x01 (VFD), 0x02 (LCD) or 0x03 (VFD+LCD).*/
   2.120 -	    DSPNM_IMON_RESTARTED,
   2.121 -
   2.122 -	    /**DSPNM_IMON_CLOSED
   2.123 -	    @brief	When iMON closed, API will post caller-specified message with DSPNM_IMON_CLOSED as WPARAM parameter.\n
   2.124 -				    LPARAM is not used.*/
   2.125 -	    DSPNM_IMON_CLOSED,
   2.126 -
   2.127 -	    /**DSPNM_HW_CONNECTED
   2.128 -	    @brief	When iMON HW newly connected, API will post caller-specified message with DSPNM_HW_CONNECTED as WPARAM parameter.\n
   2.129 -				    LPARAM represents DSPType. This value can be 0 (No Display), 0x01 (VFD), 0x02 (LCD) or 0x03 (VFD+LCD).*/
   2.130 -	    DSPNM_HW_CONNECTED,
   2.131 -
   2.132 -	    /**DSPNM_HW_DISCONNECTED
   2.133 -	    @brief	When iMON HW disconnected, API will post caller-specified message with DSPNM_HW_DISCONNECTED as WPARAM parameter.\n
   2.134 -				    LPARAM is DSPNResult value, DSPN_ERR_HW_DISCONNECTED.*/
   2.135 -	    DSPNM_HW_DISCONNECTED,
   2.136 -
   2.137 -
   2.138 -	    /**DSPNM_LCD_TEXT_SCROLL_DONE
   2.139 -	    @brief	When iMON LCD finishes scrolling Text, API will post caller-specified message with DSPNM_LCD_TEXT_SCROLL_DONE as WPARAM parameter.\n
   2.140 -				    The caller application may need to know when text scroll is finished, for sending next text.\n
   2.141 -				    LPARAM is not used.*/
   2.142 -	    DSPNM_LCD_TEXT_SCROLL_DONE = 0x1000,
   2.143 -    };
   2.144 -
   2.145 -    /// Functions
   2.146 -    [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
   2.147 -    public delegate DSPResult IMON_Display_Uninit();
   2.148 -
   2.149 -    [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
   2.150 -    public delegate DSPResult IMON_Display_Init(IntPtr hwndNoti, uint uMsgNotification);
   2.151 -
   2.152 -    [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
   2.153 -    public delegate DSPResult IMON_Display_IsInited();
   2.154 -
   2.155 -    [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
   2.156 -    public delegate DSPResult IMON_Display_IsPluginModeEnabled();
   2.157 -
   2.158 -    [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
   2.159 -    public delegate DSPResult IMON_Display_SetVfdText(
   2.160 -        [MarshalAs(UnmanagedType.LPWStr)] string lpsz1stLine,
   2.161 -        [MarshalAs(UnmanagedType.LPWStr)] string lpsz2ndLine);
   2.162 -
   2.163 -    //IMONDSPAPI DSPResult IMON_Display_SetVfdText(LPCTSTR lpsz1stLine, LPCTSTR lpsz2ndLine);
   2.164 -
   2.165 -}
   2.166 -
   2.167  
   2.168  
   2.169  namespace OpenHardwareMonitor.GUI
   2.170 @@ -180,14 +34,8 @@
   2.171          private PersistentSettings settings;
   2.172          private UnitManager unitManager;
   2.173          private List<SensorFrontView> list = new List<SensorFrontView>();
   2.174 -        //private bool mainIconEnabled = false;
   2.175 -        //private NotifyIconAdv mainIcon;
   2.176 -        IntPtr iSoundGraphDll;
   2.177 -        SoundGraph.IMON_Display_Uninit iIMON_Display_Uninit;
   2.178 -        SoundGraph.IMON_Display_Init iIMON_Display_Init;
   2.179 -        SoundGraph.IMON_Display_IsInited iIMON_Display_IsInited;
   2.180 -        SoundGraph.IMON_Display_IsPluginModeEnabled iIMON_Display_IsPluginModeEnabled;
   2.181 -        SoundGraph.IMON_Display_SetVfdText iIMON_Display_SetVfdText;
   2.182 +        private SoundGraph.Server iServer;
   2.183 +
   2.184  
   2.185          public SoundGraphDisplay(IComputer computer, PersistentSettings settings,
   2.186            UnitManager unitManager)
   2.187 @@ -198,38 +46,23 @@
   2.188              computer.HardwareAdded += new HardwareEventHandler(HardwareAdded);
   2.189              computer.HardwareRemoved += new HardwareEventHandler(HardwareRemoved);
   2.190  
   2.191 +            //Start our client if needed
   2.192 +            Process[] processes = Process.GetProcessesByName("SoundGraphAccess");
   2.193 +            if (!(processes.Length > 0))
   2.194 +            {
   2.195 +
   2.196 +                //Process client = UserAccountControl.CreateProcessAsStandardUser(@"D:\Dev\SoundGraphAccess\Debug\SoundGraphAccess.exe","");
   2.197 +                    /*
   2.198 +                Process client = new Process();
   2.199 +                client.StartInfo.FileName = @"D:\Dev\SoundGraphAccess\Debug\SoundGraphAccess.exe";
   2.200 +                client.StartInfo.WorkingDirectory = @"D:\Dev\SoundGraphAccess";
   2.201 +                client.Start();*/
   2.202 +            }
   2.203 +
   2.204              //Try loading SoundGraph iMON Disaply DLL
   2.205 -            iSoundGraphDll = NativeMethods.LoadLibraryEx(@"iMONDisplay.dll", IntPtr.Zero, NativeMethods.LoadLibraryFlags.LOAD_WITH_ALTERED_SEARCH_PATH);
   2.206 -            int err=Marshal.GetLastWin32Error(); //If you 193  it means you need build for x86
   2.207 -            if (err == 193)
   2.208 -            {
   2.209 -                Console.Write(@"iMON: Cannot load x86 DLL from x64 process.");
   2.210 -            }
   2.211 -            else if (err != 0)
   2.212 -            {
   2.213 -                Console.Write(@"iMON: Error: %i - Failed to load iMONDisplay.dll", err);
   2.214 -            }
   2.215 -            else
   2.216 -            {
   2.217 -                Console.Write(@"iMON: DLL loaded.");
   2.218 -                //Gather our function pointers
   2.219 -                //TODO: Check returned pointers for validity
   2.220 -                IntPtr functionPointer = NativeMethods.GetProcAddress(iSoundGraphDll, "IMON_Display_Uninit");
   2.221 -                iIMON_Display_Uninit = (SoundGraph.IMON_Display_Uninit)Marshal.GetDelegateForFunctionPointer(functionPointer, typeof(SoundGraph.IMON_Display_Uninit));
   2.222 -                
   2.223 -                functionPointer = NativeMethods.GetProcAddress(iSoundGraphDll, "IMON_Display_Init");
   2.224 -                iIMON_Display_Init = (SoundGraph.IMON_Display_Init)Marshal.GetDelegateForFunctionPointer(functionPointer, typeof(SoundGraph.IMON_Display_Init));
   2.225 -                
   2.226 -                functionPointer = NativeMethods.GetProcAddress(iSoundGraphDll, "IMON_Display_IsInited");
   2.227 -                iIMON_Display_IsInited = (SoundGraph.IMON_Display_IsInited)Marshal.GetDelegateForFunctionPointer(functionPointer, typeof(SoundGraph.IMON_Display_IsInited));
   2.228 -                
   2.229 -                functionPointer = NativeMethods.GetProcAddress(iSoundGraphDll, "IMON_Display_IsPluginModeEnabled");
   2.230 -                iIMON_Display_IsPluginModeEnabled = (SoundGraph.IMON_Display_IsPluginModeEnabled)Marshal.GetDelegateForFunctionPointer(functionPointer, typeof(SoundGraph.IMON_Display_IsPluginModeEnabled));
   2.231 -
   2.232 -                functionPointer = NativeMethods.GetProcAddress(iSoundGraphDll, "IMON_Display_SetVfdText");
   2.233 -                iIMON_Display_SetVfdText = (SoundGraph.IMON_Display_SetVfdText)Marshal.GetDelegateForFunctionPointer(functionPointer, typeof(SoundGraph.IMON_Display_SetVfdText));
   2.234 -
   2.235 -            }
   2.236 +            iServer = new SoundGraph.Server(@"\\.\pipe\sga-receiver", @"\\.\pipe\sga-sender");
   2.237 +            iServer.Start();
   2.238 +            //iServer.SendMessage("init:");
   2.239          }
   2.240  
   2.241          private void HardwareRemoved(IHardware hardware)
   2.242 @@ -270,11 +103,7 @@
   2.243              foreach (SensorFrontView icon in list)
   2.244                  icon.Dispose();
   2.245  
   2.246 -            //Unload our DLL
   2.247 -            if (iSoundGraphDll != IntPtr.Zero)
   2.248 -            {
   2.249 -                bool result = NativeMethods.FreeLibrary(iSoundGraphDll);
   2.250 -            }
   2.251 +            iServer.Stop();
   2.252  
   2.253          }
   2.254  
   2.255 @@ -349,19 +178,19 @@
   2.256               */
   2.257          }
   2.258  
   2.259 -        public void Init(IntPtr aHWND)
   2.260 +        public void Init()
   2.261          {
   2.262 -            iIMON_Display_Init(aHWND, SoundGraph.WM_DSP_PLUGIN_NOTIFY);
   2.263 +            iServer.SendMessage("init:");
   2.264          }
   2.265  
   2.266          public void Uninit()
   2.267          {
   2.268 -            iIMON_Display_Uninit();
   2.269 +            iServer.SendMessage("uninit:");
   2.270          }
   2.271  
   2.272          public void SetText(string aUpperLine, string aLowerLine)
   2.273          {
   2.274 -
   2.275 +            iServer.SendMessage("set-vfd-text:" + aUpperLine);
   2.276          }
   2.277  
   2.278          /*
   2.279 @@ -378,47 +207,13 @@
   2.280              }
   2.281          }*/
   2.282  
   2.283 -
   2.284 +        /*
   2.285          public bool IsDllLoaded
   2.286          {
   2.287              get { return iSoundGraphDll!=IntPtr.Zero; }
   2.288          }
   2.289 +         */
   2.290  
   2.291 -        public void DisplayPluginMessage(int uErrCode, bool bError)
   2.292 -        {
   2.293 -	        if(bError)
   2.294 -	        {
   2.295 -                switch ((SoundGraph.DSPNInitResult)uErrCode)
   2.296 -		        {
   2.297 -                    case SoundGraph.DSPNInitResult.DSPN_ERR_IN_USED: 
   2.298 -                        Console.Write("Display Plug-in is Already Used by Other Application.\n"); break;
   2.299 -                    case SoundGraph.DSPNInitResult.DSPN_ERR_HW_DISCONNECTED: 
   2.300 -                        Console.Write("iMON HW is Not Connected."); break;
   2.301 -                    case SoundGraph.DSPNInitResult.DSPN_ERR_NOT_SUPPORTED_HW: 
   2.302 -                        Console.Write("The Connected iMON HW doesn't Support Display Plug-in.\n"); break;
   2.303 -                    case SoundGraph.DSPNInitResult.DSPN_ERR_PLUGIN_DISABLED: 
   2.304 -                        Console.Write("Display Plug-in Mode Option is Disabled.\n"); break;
   2.305 -                    case SoundGraph.DSPNInitResult.DSPN_ERR_IMON_NO_REPLY: 
   2.306 -                        Console.Write("The Latest iMON is Not Installed or iMON Not Running.\n"); break;
   2.307 -                    case SoundGraph.DSPNInitResult.DSPN_ERR_UNKNOWN: 
   2.308 -                        Console.Write("Unknown Failure.\n"); break;
   2.309 -		        }
   2.310 -    	    }
   2.311 -	        else
   2.312 -            {
   2.313 -                switch ((SoundGraph.DSPNotifyCode)uErrCode)
   2.314 -		        {
   2.315 -                    case SoundGraph.DSPNotifyCode.DSPNM_PLUGIN_SUCCEED: 
   2.316 -                        Console.Write("Plug-in Mode Inited Successfully.\n"); break;
   2.317 -                    case SoundGraph.DSPNotifyCode.DSPNM_IMON_RESTARTED: 
   2.318 -                        Console.Write("iMON Started and Plug-in Mode Inited.\n"); break;
   2.319 -                    case SoundGraph.DSPNotifyCode.DSPNM_HW_CONNECTED: 
   2.320 -                        Console.Write("iMON HW Connected and Plug-in Mode Inited.\n"); break;
   2.321 -		        }
   2.322 -	        }
   2.323 -	    
   2.324 -            //GetDlgItem(IDC_STATIC_INFO)->SetWindowText((LPCTSTR)strErrMsg);
   2.325 -        }
   2.326  
   2.327      }
   2.328  }
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/GUI/SoundGraphServer.cs	Sat Feb 09 17:18:09 2013 +0100
     3.3 @@ -0,0 +1,220 @@
     3.4 +using System;
     3.5 +using Microsoft.Win32.SafeHandles;
     3.6 +using System.Text;
     3.7 +using System.Runtime.InteropServices;
     3.8 +using System.Threading;
     3.9 +using System.IO;
    3.10 +using System.Diagnostics;
    3.11 +
    3.12 +namespace SoundGraph
    3.13 +{
    3.14 +    public class Server
    3.15 +    {
    3.16 +        [DllImport("kernel32.dll", SetLastError = true)]
    3.17 +        public static extern SafeFileHandle CreateNamedPipe(
    3.18 +           String pipeName,
    3.19 +           uint dwOpenMode,
    3.20 +           uint dwPipeMode,
    3.21 +           uint nMaxInstances,
    3.22 +           uint nOutBufferSize,
    3.23 +           uint nInBufferSize,
    3.24 +           uint nDefaultTimeOut,
    3.25 +           IntPtr lpSecurityAttributes);
    3.26 +
    3.27 +        [DllImport("kernel32.dll", SetLastError = true)]
    3.28 +        public static extern int ConnectNamedPipe(
    3.29 +           SafeFileHandle hNamedPipe,
    3.30 +           IntPtr lpOverlapped);
    3.31 +
    3.32 +        [DllImport("kernel32.dll", SetLastError = true)]
    3.33 +        public static extern int DisconnectNamedPipe(
    3.34 +           SafeFileHandle hNamedPipe);
    3.35 +
    3.36 +        public const uint PIPE_ACCESS_DUPLEX = (0x00000003);
    3.37 +        public const uint FILE_FLAG_OVERLAPPED = (0x40000000);
    3.38 +        public const uint PIPE_ACCESS_OUTBOUND = (0x00000002);
    3.39 +        public const uint PIPE_ACCESS_INBOUND = (0x00000001);
    3.40 +        public const uint PIPE_TYPE_BYTE = (0x00000000);
    3.41 +        public const uint PIPE_UNLIMITED_INSTANCES = 255;
    3.42 +          
    3.43 +        
    3.44 +
    3.45 +
    3.46 +        public const int BUFFER_SIZE = 256;
    3.47 +
    3.48 +        //
    3.49 +        public string iPipeNameOutbound;
    3.50 +        Thread iThreadOutbound;
    3.51 +        SafeFileHandle iPipeOutbound;
    3.52 +        public FileStream iStreamOutbound;
    3.53 +        //
    3.54 +        public string iPipeNameInbound;
    3.55 +        Thread iThreadInbound;
    3.56 +        SafeFileHandle iPipeInbound;
    3.57 +        public FileStream iStreamInbound;
    3.58 +
    3.59 +
    3.60 +        public Server(string aPipeNameOutbound, string aPipeNameInbound)
    3.61 +        {
    3.62 +            iPipeNameOutbound = aPipeNameOutbound;
    3.63 +            iPipeNameInbound = aPipeNameInbound;
    3.64 +        }
    3.65 +       
    3.66 +        /**
    3.67 +         * Start our services.
    3.68 +         */
    3.69 +        public void Start()
    3.70 +        {
    3.71 +            //Start outbound thread to send messages
    3.72 +            this.iThreadOutbound = new Thread(new ThreadStart(ThreadOutbound));
    3.73 +            this.iThreadOutbound.Start();
    3.74 +            //Start inbound thread to receive messages
    3.75 +            this.iThreadInbound = new Thread(new ThreadStart(ThreadInbound));
    3.76 +            this.iThreadInbound.Start();
    3.77 +        }
    3.78 +
    3.79 +        /**
    3.80 +         * Outbound thread is sending messages to our client.
    3.81 +         */
    3.82 +        private void ThreadOutbound()
    3.83 +        {
    3.84 +            
    3.85 +            //Create our outbound named pipe
    3.86 +            iPipeOutbound = CreateNamedPipe(this.iPipeNameOutbound, PIPE_ACCESS_OUTBOUND /*| FILE_FLAG_OVERLAPPED*/, PIPE_TYPE_BYTE, PIPE_UNLIMITED_INSTANCES, BUFFER_SIZE, BUFFER_SIZE, 0, IntPtr.Zero);
    3.87 +
    3.88 +            //Could not create named pipe
    3.89 +            if (iPipeOutbound.IsInvalid)
    3.90 +            {
    3.91 +                //TODO: error handling
    3.92 +                return;
    3.93 +            }
    3.94 +
    3.95 +            //Will complete once our client connects
    3.96 +            int success = ConnectNamedPipe(iPipeOutbound, IntPtr.Zero);
    3.97 +
    3.98 +            //could not connect client
    3.99 +            if (success == 0)
   3.100 +            {
   3.101 +                //TODO: error handling
   3.102 +                return;
   3.103 +            }
   3.104 +
   3.105 +            //Client now connected create our stream
   3.106 +            iStreamOutbound = new FileStream(iPipeOutbound, FileAccess.Write, BUFFER_SIZE, false);
   3.107 + 
   3.108 +        }
   3.109 +
   3.110 +        /**
   3.111 +         * Inbound thread is receiving messages from our client
   3.112 +         */
   3.113 +        private void ThreadInbound()
   3.114 +        {
   3.115 +            //Client client = (Client)clientObj;
   3.116 +            //clientse.stream = new FileStream(clientse.handle, FileAccess.ReadWrite, BUFFER_SIZE, true);
   3.117 +
   3.118 +            iPipeInbound = CreateNamedPipe(this.iPipeNameInbound, PIPE_ACCESS_INBOUND, PIPE_TYPE_BYTE, PIPE_UNLIMITED_INSTANCES, BUFFER_SIZE, BUFFER_SIZE, 0, IntPtr.Zero);
   3.119 +
   3.120 +            //could not create named pipe
   3.121 +            if (iPipeInbound.IsInvalid)
   3.122 +                return;
   3.123 +
   3.124 +            //Will complete once a client connects
   3.125 +            int success = ConnectNamedPipe(iPipeInbound, IntPtr.Zero);
   3.126 +
   3.127 +            //could not connect client
   3.128 +            if (success == 0)
   3.129 +                return;
   3.130 +
   3.131 +            //Client now connected create our inbound stream
   3.132 +            iStreamInbound = new FileStream(iPipeInbound, FileAccess.Read, BUFFER_SIZE, false);
   3.133 +
   3.134 +
   3.135 +            byte[] buffer = null;
   3.136 +            ASCIIEncoding encoder = new ASCIIEncoding();
   3.137 +
   3.138 +            while (true)
   3.139 +            {                
   3.140 +                int bytesRead = 0;
   3.141 +
   3.142 +                try
   3.143 +                {
   3.144 +                    buffer = new byte[BUFFER_SIZE];
   3.145 +                    bytesRead = iStreamInbound.Read(buffer, 0, BUFFER_SIZE);
   3.146 +                }
   3.147 +                catch
   3.148 +                {
   3.149 +                    //read error has occurred
   3.150 +                    break;
   3.151 +                }
   3.152 +
   3.153 +                //client has disconnected
   3.154 +                if (bytesRead == 0)
   3.155 +                    break;
   3.156 +
   3.157 +                //fire message received event
   3.158 +                //if (this.MessageReceived != null)
   3.159 +                //    this.MessageReceived(clientse, encoder.GetString(buffer, 0, bytesRead));
   3.160 +
   3.161 +                int ReadLength = 0;
   3.162 +                for (int i = 0; i < BUFFER_SIZE; i++)
   3.163 +                {
   3.164 +                    //if (buffer[i].ToString("x2") != "cc")
   3.165 +                    if (buffer[i] != 0)
   3.166 +                    {
   3.167 +                        ReadLength++;
   3.168 +                    }
   3.169 +                    else
   3.170 +                        break;
   3.171 +                }
   3.172 +                if (ReadLength > 0)
   3.173 +                {
   3.174 +                    byte[] Rc = new byte[ReadLength];
   3.175 +                    Buffer.BlockCopy(buffer, 0, Rc, 0, ReadLength);
   3.176 +
   3.177 +                    Console.WriteLine(encoder.GetString(Rc, 0, ReadLength));
   3.178 +                    Trace.WriteLine("Received " + ReadLength + " Bytes: " + encoder.GetString(Rc, 0, ReadLength));
   3.179 +                    buffer.Initialize();
   3.180 +                }
   3.181 +               
   3.182 +            }
   3.183 +
   3.184 +            //clean up resources
   3.185 +            iStreamInbound.Close();
   3.186 +            iPipeInbound.Close();            
   3.187 +        }
   3.188 +
   3.189 +        /**
   3.190 +         * Send a message to our client.
   3.191 +         */
   3.192 +        public void SendMessage(string message)
   3.193 +        {
   3.194 +
   3.195 +                ASCIIEncoding encoder = new ASCIIEncoding();
   3.196 +                byte[] messageBuffer = encoder.GetBytes(message);
   3.197 +
   3.198 +                if (iStreamOutbound.CanWrite)
   3.199 +                {
   3.200 +                    iStreamOutbound.Write(messageBuffer, 0, messageBuffer.Length);
   3.201 +                    iStreamOutbound.Flush();
   3.202 +                }
   3.203 +
   3.204 +
   3.205 +        }
   3.206 +
   3.207 +        /**
   3.208 +         * 
   3.209 +         */
   3.210 +        public void Stop()
   3.211 +        {
   3.212 +            //clean up resources
   3.213 +
   3.214 +            DisconnectNamedPipe(this.iPipeOutbound);
   3.215 +
   3.216 +            //TODO: more cleanup
   3.217 +            
   3.218 +
   3.219 +            this.iThreadOutbound.Abort();
   3.220 +        }
   3.221 +
   3.222 +    }
   3.223 +}
     4.1 --- a/OpenHardwareMonitor.csproj	Mon Feb 04 00:47:01 2013 +0100
     4.2 +++ b/OpenHardwareMonitor.csproj	Sat Feb 09 17:18:09 2013 +0100
     4.3 @@ -9,7 +9,7 @@
     4.4      <OutputType>WinExe</OutputType>
     4.5      <NoStandardLibraries>false</NoStandardLibraries>
     4.6      <AssemblyName>OpenHardwareMonitor</AssemblyName>
     4.7 -    <TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
     4.8 +    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
     4.9      <FileAlignment>512</FileAlignment>
    4.10      <RootNamespace>OpenHardwareMonitor</RootNamespace>
    4.11      <ApplicationIcon>Resources\icon.ico</ApplicationIcon>
    4.12 @@ -34,12 +34,13 @@
    4.13      <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
    4.14      <UseApplicationTrust>false</UseApplicationTrust>
    4.15      <BootstrapperEnabled>true</BootstrapperEnabled>
    4.16 +    <TargetFrameworkProfile />
    4.17    </PropertyGroup>
    4.18    <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    4.19      <DebugSymbols>true</DebugSymbols>
    4.20      <DebugType>full</DebugType>
    4.21      <Optimize>false</Optimize>
    4.22 -    <OutputPath>Bin\Debug\</OutputPath>
    4.23 +    <OutputPath>output\</OutputPath>
    4.24      <DefineConstants>TRACE;DEBUG</DefineConstants>
    4.25      <ErrorReport>prompt</ErrorReport>
    4.26      <WarningLevel>4</WarningLevel>
    4.27 @@ -50,7 +51,7 @@
    4.28    <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    4.29      <DebugType>none</DebugType>
    4.30      <Optimize>true</Optimize>
    4.31 -    <OutputPath>Bin\Release\</OutputPath>
    4.32 +    <OutputPath>output\</OutputPath>
    4.33      <DefineConstants>TRACE</DefineConstants>
    4.34      <ErrorReport>prompt</ErrorReport>
    4.35      <WarningLevel>4</WarningLevel>
    4.36 @@ -125,6 +126,7 @@
    4.37      <Compile Include="GUI\SensorNotifyIcon.cs" />
    4.38      <Compile Include="GUI\ShowDesktop.cs" />
    4.39      <Compile Include="GUI\SoundGraphDisplay.cs" />
    4.40 +    <Compile Include="GUI\SoundGraphServer.cs" />
    4.41      <Compile Include="GUI\SplitContainerAdv.cs">
    4.42        <SubType>Component</SubType>
    4.43      </Compile>
    4.44 @@ -226,6 +228,10 @@
    4.45        <Project>{B0397530-545A-471D-BB74-027AE456DF1A}</Project>
    4.46        <Name>OpenHardwareMonitorLib</Name>
    4.47      </ProjectReference>
    4.48 +    <ProjectReference Include="UacHelpers.CppLibrary\UacHelpers.CppLibrary.vcxproj">
    4.49 +      <Project>{d043a646-fe7a-4334-b23d-e327593c1ae2}</Project>
    4.50 +      <Name>UacHelpers.UserAccountControl</Name>
    4.51 +    </ProjectReference>
    4.52    </ItemGroup>
    4.53    <ItemGroup>
    4.54      <BootstrapperPackage Include="Microsoft.Net.Client.3.5">
     5.1 --- a/OpenHardwareMonitor.sln	Mon Feb 04 00:47:01 2013 +0100
     5.2 +++ b/OpenHardwareMonitor.sln	Sat Feb 09 17:18:09 2013 +0100
     5.3 @@ -8,30 +8,77 @@
     5.4  		{B0397530-545A-471D-BB74-027AE456DF1A} = {B0397530-545A-471D-BB74-027AE456DF1A}
     5.5  	EndProjectSection
     5.6  EndProject
     5.7 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UacHelpers.UserAccountControl", "UacHelpers.CppLibrary\UacHelpers.CppLibrary.vcxproj", "{D043A646-FE7A-4334-B23D-E327593C1AE2}"
     5.8 +EndProject
     5.9  Global
    5.10  	GlobalSection(SolutionConfigurationPlatforms) = preSolution
    5.11  		Debug|Any CPU = Debug|Any CPU
    5.12 +		Debug|Mixed Platforms = Debug|Mixed Platforms
    5.13 +		Debug|Win32 = Debug|Win32
    5.14 +		Debug|x64 = Debug|x64
    5.15  		Debug|x86 = Debug|x86
    5.16  		Release|Any CPU = Release|Any CPU
    5.17 +		Release|Mixed Platforms = Release|Mixed Platforms
    5.18 +		Release|Win32 = Release|Win32
    5.19 +		Release|x64 = Release|x64
    5.20  		Release|x86 = Release|x86
    5.21  	EndGlobalSection
    5.22  	GlobalSection(ProjectConfigurationPlatforms) = postSolution
    5.23  		{B0397530-545A-471D-BB74-027AE456DF1A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
    5.24  		{B0397530-545A-471D-BB74-027AE456DF1A}.Debug|Any CPU.Build.0 = Debug|Any CPU
    5.25 +		{B0397530-545A-471D-BB74-027AE456DF1A}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
    5.26 +		{B0397530-545A-471D-BB74-027AE456DF1A}.Debug|Mixed Platforms.Build.0 = Debug|x86
    5.27 +		{B0397530-545A-471D-BB74-027AE456DF1A}.Debug|Win32.ActiveCfg = Debug|x86
    5.28 +		{B0397530-545A-471D-BB74-027AE456DF1A}.Debug|Win32.Build.0 = Debug|x86
    5.29 +		{B0397530-545A-471D-BB74-027AE456DF1A}.Debug|x64.ActiveCfg = Debug|Any CPU
    5.30  		{B0397530-545A-471D-BB74-027AE456DF1A}.Debug|x86.ActiveCfg = Debug|x86
    5.31  		{B0397530-545A-471D-BB74-027AE456DF1A}.Debug|x86.Build.0 = Debug|x86
    5.32  		{B0397530-545A-471D-BB74-027AE456DF1A}.Release|Any CPU.ActiveCfg = Release|Any CPU
    5.33  		{B0397530-545A-471D-BB74-027AE456DF1A}.Release|Any CPU.Build.0 = Release|Any CPU
    5.34 +		{B0397530-545A-471D-BB74-027AE456DF1A}.Release|Mixed Platforms.ActiveCfg = Release|x86
    5.35 +		{B0397530-545A-471D-BB74-027AE456DF1A}.Release|Mixed Platforms.Build.0 = Release|x86
    5.36 +		{B0397530-545A-471D-BB74-027AE456DF1A}.Release|Win32.ActiveCfg = Release|x86
    5.37 +		{B0397530-545A-471D-BB74-027AE456DF1A}.Release|Win32.Build.0 = Release|x86
    5.38 +		{B0397530-545A-471D-BB74-027AE456DF1A}.Release|x64.ActiveCfg = Release|Any CPU
    5.39  		{B0397530-545A-471D-BB74-027AE456DF1A}.Release|x86.ActiveCfg = Release|x86
    5.40  		{B0397530-545A-471D-BB74-027AE456DF1A}.Release|x86.Build.0 = Release|x86
    5.41  		{F5E0C1F7-9E9B-46F2-AC88-8C9C1C923880}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
    5.42  		{F5E0C1F7-9E9B-46F2-AC88-8C9C1C923880}.Debug|Any CPU.Build.0 = Debug|Any CPU
    5.43 +		{F5E0C1F7-9E9B-46F2-AC88-8C9C1C923880}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
    5.44 +		{F5E0C1F7-9E9B-46F2-AC88-8C9C1C923880}.Debug|Mixed Platforms.Build.0 = Debug|x86
    5.45 +		{F5E0C1F7-9E9B-46F2-AC88-8C9C1C923880}.Debug|Win32.ActiveCfg = Debug|x86
    5.46 +		{F5E0C1F7-9E9B-46F2-AC88-8C9C1C923880}.Debug|Win32.Build.0 = Debug|x86
    5.47 +		{F5E0C1F7-9E9B-46F2-AC88-8C9C1C923880}.Debug|x64.ActiveCfg = Debug|Any CPU
    5.48  		{F5E0C1F7-9E9B-46F2-AC88-8C9C1C923880}.Debug|x86.ActiveCfg = Debug|x86
    5.49  		{F5E0C1F7-9E9B-46F2-AC88-8C9C1C923880}.Debug|x86.Build.0 = Debug|x86
    5.50  		{F5E0C1F7-9E9B-46F2-AC88-8C9C1C923880}.Release|Any CPU.ActiveCfg = Release|Any CPU
    5.51  		{F5E0C1F7-9E9B-46F2-AC88-8C9C1C923880}.Release|Any CPU.Build.0 = Release|Any CPU
    5.52 +		{F5E0C1F7-9E9B-46F2-AC88-8C9C1C923880}.Release|Mixed Platforms.ActiveCfg = Release|x86
    5.53 +		{F5E0C1F7-9E9B-46F2-AC88-8C9C1C923880}.Release|Mixed Platforms.Build.0 = Release|x86
    5.54 +		{F5E0C1F7-9E9B-46F2-AC88-8C9C1C923880}.Release|Win32.ActiveCfg = Release|x86
    5.55 +		{F5E0C1F7-9E9B-46F2-AC88-8C9C1C923880}.Release|Win32.Build.0 = Release|x86
    5.56 +		{F5E0C1F7-9E9B-46F2-AC88-8C9C1C923880}.Release|x64.ActiveCfg = Release|Any CPU
    5.57  		{F5E0C1F7-9E9B-46F2-AC88-8C9C1C923880}.Release|x86.ActiveCfg = Release|x86
    5.58  		{F5E0C1F7-9E9B-46F2-AC88-8C9C1C923880}.Release|x86.Build.0 = Release|x86
    5.59 +		{D043A646-FE7A-4334-B23D-E327593C1AE2}.Debug|Any CPU.ActiveCfg = Debug|x64
    5.60 +		{D043A646-FE7A-4334-B23D-E327593C1AE2}.Debug|Any CPU.Build.0 = Debug|x64
    5.61 +		{D043A646-FE7A-4334-B23D-E327593C1AE2}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
    5.62 +		{D043A646-FE7A-4334-B23D-E327593C1AE2}.Debug|Mixed Platforms.Build.0 = Debug|Win32
    5.63 +		{D043A646-FE7A-4334-B23D-E327593C1AE2}.Debug|Win32.ActiveCfg = Debug|Win32
    5.64 +		{D043A646-FE7A-4334-B23D-E327593C1AE2}.Debug|Win32.Build.0 = Debug|Win32
    5.65 +		{D043A646-FE7A-4334-B23D-E327593C1AE2}.Debug|x64.ActiveCfg = Debug|x64
    5.66 +		{D043A646-FE7A-4334-B23D-E327593C1AE2}.Debug|x64.Build.0 = Debug|x64
    5.67 +		{D043A646-FE7A-4334-B23D-E327593C1AE2}.Debug|x86.ActiveCfg = Debug|Win32
    5.68 +		{D043A646-FE7A-4334-B23D-E327593C1AE2}.Debug|x86.Build.0 = Debug|Win32
    5.69 +		{D043A646-FE7A-4334-B23D-E327593C1AE2}.Release|Any CPU.ActiveCfg = Release|Win32
    5.70 +		{D043A646-FE7A-4334-B23D-E327593C1AE2}.Release|Mixed Platforms.ActiveCfg = Release|Win32
    5.71 +		{D043A646-FE7A-4334-B23D-E327593C1AE2}.Release|Mixed Platforms.Build.0 = Release|Win32
    5.72 +		{D043A646-FE7A-4334-B23D-E327593C1AE2}.Release|Win32.ActiveCfg = Release|Win32
    5.73 +		{D043A646-FE7A-4334-B23D-E327593C1AE2}.Release|Win32.Build.0 = Release|Win32
    5.74 +		{D043A646-FE7A-4334-B23D-E327593C1AE2}.Release|x64.ActiveCfg = Release|x64
    5.75 +		{D043A646-FE7A-4334-B23D-E327593C1AE2}.Release|x64.Build.0 = Release|x64
    5.76 +		{D043A646-FE7A-4334-B23D-E327593C1AE2}.Release|x86.ActiveCfg = Release|Win32
    5.77 +		{D043A646-FE7A-4334-B23D-E327593C1AE2}.Release|x86.Build.0 = Release|Win32
    5.78  	EndGlobalSection
    5.79  	GlobalSection(SolutionProperties) = preSolution
    5.80  		HideSolutionNode = FALSE
     6.1 --- a/OpenHardwareMonitorLib.csproj	Mon Feb 04 00:47:01 2013 +0100
     6.2 +++ b/OpenHardwareMonitorLib.csproj	Sat Feb 09 17:18:09 2013 +0100
     6.3 @@ -10,7 +10,7 @@
     6.4      <AppDesignerFolder>Properties</AppDesignerFolder>
     6.5      <RootNamespace>OpenHardwareMonitor</RootNamespace>
     6.6      <AssemblyName>OpenHardwareMonitorLib</AssemblyName>
     6.7 -    <TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
     6.8 +    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
     6.9      <FileAlignment>512</FileAlignment>
    6.10      <FileUpgradeFlags>
    6.11      </FileUpgradeFlags>
    6.12 @@ -31,12 +31,13 @@
    6.13      <IsWebBootstrapper>false</IsWebBootstrapper>
    6.14      <UseApplicationTrust>false</UseApplicationTrust>
    6.15      <BootstrapperEnabled>true</BootstrapperEnabled>
    6.16 +    <TargetFrameworkProfile />
    6.17    </PropertyGroup>
    6.18    <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    6.19      <DebugSymbols>true</DebugSymbols>
    6.20      <DebugType>full</DebugType>
    6.21      <Optimize>false</Optimize>
    6.22 -    <OutputPath>Bin\Debug\</OutputPath>
    6.23 +    <OutputPath>output\</OutputPath>
    6.24      <DefineConstants>TRACE;DEBUG</DefineConstants>
    6.25      <ErrorReport>prompt</ErrorReport>
    6.26      <WarningLevel>4</WarningLevel>
    6.27 @@ -45,7 +46,7 @@
    6.28    <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    6.29      <DebugType>none</DebugType>
    6.30      <Optimize>true</Optimize>
    6.31 -    <OutputPath>Bin\Release\</OutputPath>
    6.32 +    <OutputPath>output\</OutputPath>
    6.33      <DefineConstants>TRACE</DefineConstants>
    6.34      <ErrorReport>prompt</ErrorReport>
    6.35      <WarningLevel>4</WarningLevel>
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/UacHelpers.CppLibrary/AssemblyInfo.cpp	Sat Feb 09 17:18:09 2013 +0100
     7.3 @@ -0,0 +1,38 @@
     7.4 +using namespace System;
     7.5 +using namespace System::Reflection;
     7.6 +using namespace System::Runtime::CompilerServices;
     7.7 +using namespace System::Runtime::InteropServices;
     7.8 +using namespace System::Security::Permissions;
     7.9 +
    7.10 +//
    7.11 +// General Information about an assembly is controlled through the following
    7.12 +// set of attributes. Change these attribute values to modify the information
    7.13 +// associated with an assembly.
    7.14 +//
    7.15 +[assembly:AssemblyTitleAttribute("UAC Helpers")];
    7.16 +[assembly:AssemblyDescriptionAttribute("User Account Control C++/CLI Library")];
    7.17 +[assembly:AssemblyConfigurationAttribute("")];
    7.18 +[assembly:AssemblyCompanyAttribute("Sela Group")];
    7.19 +[assembly:AssemblyProductAttribute("")];
    7.20 +[assembly:AssemblyCopyrightAttribute("Copyright (c) Sasha Goldshtein 2008")];
    7.21 +[assembly:AssemblyTrademarkAttribute("")];
    7.22 +[assembly:AssemblyCultureAttribute("")];
    7.23 +
    7.24 +//
    7.25 +// Version information for an assembly consists of the following four values:
    7.26 +//
    7.27 +//      Major Version
    7.28 +//      Minor Version
    7.29 +//      Build Number
    7.30 +//      Revision
    7.31 +//
    7.32 +// You can specify all the value or you can default the Revision and Build Numbers
    7.33 +// by using the '*' as shown below:
    7.34 +
    7.35 +[assembly:AssemblyVersionAttribute("1.0.0.0")];
    7.36 +
    7.37 +[assembly:ComVisible(false)];
    7.38 +
    7.39 +[assembly:CLSCompliantAttribute(true)];
    7.40 +
    7.41 +[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)];
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/UacHelpers.CppLibrary/UacHelpers.CppLibrary.vcproj	Sat Feb 09 17:18:09 2013 +0100
     8.3 @@ -0,0 +1,368 @@
     8.4 +<?xml version="1.0" encoding="windows-1255"?>
     8.5 +<VisualStudioProject
     8.6 +	ProjectType="Visual C++"
     8.7 +	Version="9.00"
     8.8 +	Name="UacHelpers.UserAccountControl"
     8.9 +	ProjectGUID="{D043A646-FE7A-4334-B23D-E327593C1AE2}"
    8.10 +	RootNamespace="UacHelpersCppLibrary"
    8.11 +	SccProjectName="SAK"
    8.12 +	SccAuxPath="SAK"
    8.13 +	SccLocalPath="SAK"
    8.14 +	SccProvider="SAK"
    8.15 +	Keyword="ManagedCProj"
    8.16 +	TargetFrameworkVersion="131072"
    8.17 +	>
    8.18 +	<Platforms>
    8.19 +		<Platform
    8.20 +			Name="Win32"
    8.21 +		/>
    8.22 +		<Platform
    8.23 +			Name="x64"
    8.24 +		/>
    8.25 +	</Platforms>
    8.26 +	<ToolFiles>
    8.27 +	</ToolFiles>
    8.28 +	<Configurations>
    8.29 +		<Configuration
    8.30 +			Name="Debug|Win32"
    8.31 +			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
    8.32 +			IntermediateDirectory="$(ConfigurationName)"
    8.33 +			ConfigurationType="2"
    8.34 +			CharacterSet="1"
    8.35 +			ManagedExtensions="2"
    8.36 +			>
    8.37 +			<Tool
    8.38 +				Name="VCPreBuildEventTool"
    8.39 +			/>
    8.40 +			<Tool
    8.41 +				Name="VCCustomBuildTool"
    8.42 +			/>
    8.43 +			<Tool
    8.44 +				Name="VCXMLDataGeneratorTool"
    8.45 +			/>
    8.46 +			<Tool
    8.47 +				Name="VCWebServiceProxyGeneratorTool"
    8.48 +			/>
    8.49 +			<Tool
    8.50 +				Name="VCMIDLTool"
    8.51 +			/>
    8.52 +			<Tool
    8.53 +				Name="VCCLCompilerTool"
    8.54 +				Optimization="0"
    8.55 +				PreprocessorDefinitions="WIN32;_DEBUG"
    8.56 +				RuntimeLibrary="3"
    8.57 +				UsePrecompiledHeader="0"
    8.58 +				GenerateXMLDocumentationFiles="true"
    8.59 +				WarningLevel="3"
    8.60 +				DebugInformationFormat="3"
    8.61 +			/>
    8.62 +			<Tool
    8.63 +				Name="VCManagedResourceCompilerTool"
    8.64 +			/>
    8.65 +			<Tool
    8.66 +				Name="VCResourceCompilerTool"
    8.67 +			/>
    8.68 +			<Tool
    8.69 +				Name="VCPreLinkEventTool"
    8.70 +			/>
    8.71 +			<Tool
    8.72 +				Name="VCLinkerTool"
    8.73 +				AdditionalDependencies="$(NoInherit)"
    8.74 +				LinkIncremental="2"
    8.75 +				GenerateDebugInformation="true"
    8.76 +				AssemblyDebug="1"
    8.77 +				RandomizedBaseAddress="1"
    8.78 +				DataExecutionPrevention="0"
    8.79 +				TargetMachine="1"
    8.80 +			/>
    8.81 +			<Tool
    8.82 +				Name="VCALinkTool"
    8.83 +			/>
    8.84 +			<Tool
    8.85 +				Name="VCManifestTool"
    8.86 +			/>
    8.87 +			<Tool
    8.88 +				Name="VCXDCMakeTool"
    8.89 +			/>
    8.90 +			<Tool
    8.91 +				Name="VCBscMakeTool"
    8.92 +			/>
    8.93 +			<Tool
    8.94 +				Name="VCFxCopTool"
    8.95 +			/>
    8.96 +			<Tool
    8.97 +				Name="VCAppVerifierTool"
    8.98 +			/>
    8.99 +			<Tool
   8.100 +				Name="VCPostBuildEventTool"
   8.101 +			/>
   8.102 +		</Configuration>
   8.103 +		<Configuration
   8.104 +			Name="Debug|x64"
   8.105 +			OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
   8.106 +			IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
   8.107 +			ConfigurationType="2"
   8.108 +			CharacterSet="1"
   8.109 +			ManagedExtensions="1"
   8.110 +			>
   8.111 +			<Tool
   8.112 +				Name="VCPreBuildEventTool"
   8.113 +			/>
   8.114 +			<Tool
   8.115 +				Name="VCCustomBuildTool"
   8.116 +			/>
   8.117 +			<Tool
   8.118 +				Name="VCXMLDataGeneratorTool"
   8.119 +			/>
   8.120 +			<Tool
   8.121 +				Name="VCWebServiceProxyGeneratorTool"
   8.122 +			/>
   8.123 +			<Tool
   8.124 +				Name="VCMIDLTool"
   8.125 +				TargetEnvironment="3"
   8.126 +			/>
   8.127 +			<Tool
   8.128 +				Name="VCCLCompilerTool"
   8.129 +				Optimization="0"
   8.130 +				PreprocessorDefinitions="WIN32;_DEBUG"
   8.131 +				RuntimeLibrary="3"
   8.132 +				UsePrecompiledHeader="0"
   8.133 +				GenerateXMLDocumentationFiles="true"
   8.134 +				WarningLevel="3"
   8.135 +				DebugInformationFormat="3"
   8.136 +			/>
   8.137 +			<Tool
   8.138 +				Name="VCManagedResourceCompilerTool"
   8.139 +			/>
   8.140 +			<Tool
   8.141 +				Name="VCResourceCompilerTool"
   8.142 +			/>
   8.143 +			<Tool
   8.144 +				Name="VCPreLinkEventTool"
   8.145 +			/>
   8.146 +			<Tool
   8.147 +				Name="VCLinkerTool"
   8.148 +				AdditionalDependencies="$(NoInherit)"
   8.149 +				LinkIncremental="2"
   8.150 +				GenerateDebugInformation="true"
   8.151 +				AssemblyDebug="1"
   8.152 +				RandomizedBaseAddress="1"
   8.153 +				DataExecutionPrevention="0"
   8.154 +				TargetMachine="17"
   8.155 +			/>
   8.156 +			<Tool
   8.157 +				Name="VCALinkTool"
   8.158 +			/>
   8.159 +			<Tool
   8.160 +				Name="VCManifestTool"
   8.161 +			/>
   8.162 +			<Tool
   8.163 +				Name="VCXDCMakeTool"
   8.164 +			/>
   8.165 +			<Tool
   8.166 +				Name="VCBscMakeTool"
   8.167 +			/>
   8.168 +			<Tool
   8.169 +				Name="VCFxCopTool"
   8.170 +			/>
   8.171 +			<Tool
   8.172 +				Name="VCAppVerifierTool"
   8.173 +			/>
   8.174 +			<Tool
   8.175 +				Name="VCPostBuildEventTool"
   8.176 +			/>
   8.177 +		</Configuration>
   8.178 +		<Configuration
   8.179 +			Name="Release|Win32"
   8.180 +			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
   8.181 +			IntermediateDirectory="$(ConfigurationName)"
   8.182 +			ConfigurationType="2"
   8.183 +			CharacterSet="1"
   8.184 +			ManagedExtensions="1"
   8.185 +			WholeProgramOptimization="1"
   8.186 +			>
   8.187 +			<Tool
   8.188 +				Name="VCPreBuildEventTool"
   8.189 +			/>
   8.190 +			<Tool
   8.191 +				Name="VCCustomBuildTool"
   8.192 +			/>
   8.193 +			<Tool
   8.194 +				Name="VCXMLDataGeneratorTool"
   8.195 +			/>
   8.196 +			<Tool
   8.197 +				Name="VCWebServiceProxyGeneratorTool"
   8.198 +			/>
   8.199 +			<Tool
   8.200 +				Name="VCMIDLTool"
   8.201 +			/>
   8.202 +			<Tool
   8.203 +				Name="VCCLCompilerTool"
   8.204 +				PreprocessorDefinitions="WIN32;NDEBUG"
   8.205 +				RuntimeLibrary="2"
   8.206 +				UsePrecompiledHeader="0"
   8.207 +				GenerateXMLDocumentationFiles="true"
   8.208 +				WarningLevel="3"
   8.209 +				DebugInformationFormat="3"
   8.210 +			/>
   8.211 +			<Tool
   8.212 +				Name="VCManagedResourceCompilerTool"
   8.213 +			/>
   8.214 +			<Tool
   8.215 +				Name="VCResourceCompilerTool"
   8.216 +			/>
   8.217 +			<Tool
   8.218 +				Name="VCPreLinkEventTool"
   8.219 +			/>
   8.220 +			<Tool
   8.221 +				Name="VCLinkerTool"
   8.222 +				AdditionalDependencies="$(NoInherit)"
   8.223 +				LinkIncremental="1"
   8.224 +				GenerateDebugInformation="true"
   8.225 +				RandomizedBaseAddress="1"
   8.226 +				DataExecutionPrevention="0"
   8.227 +				TargetMachine="1"
   8.228 +			/>
   8.229 +			<Tool
   8.230 +				Name="VCALinkTool"
   8.231 +			/>
   8.232 +			<Tool
   8.233 +				Name="VCManifestTool"
   8.234 +			/>
   8.235 +			<Tool
   8.236 +				Name="VCXDCMakeTool"
   8.237 +			/>
   8.238 +			<Tool
   8.239 +				Name="VCBscMakeTool"
   8.240 +			/>
   8.241 +			<Tool
   8.242 +				Name="VCFxCopTool"
   8.243 +			/>
   8.244 +			<Tool
   8.245 +				Name="VCAppVerifierTool"
   8.246 +			/>
   8.247 +			<Tool
   8.248 +				Name="VCPostBuildEventTool"
   8.249 +			/>
   8.250 +		</Configuration>
   8.251 +		<Configuration
   8.252 +			Name="Release|x64"
   8.253 +			OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
   8.254 +			IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
   8.255 +			ConfigurationType="2"
   8.256 +			CharacterSet="1"
   8.257 +			ManagedExtensions="1"
   8.258 +			WholeProgramOptimization="1"
   8.259 +			>
   8.260 +			<Tool
   8.261 +				Name="VCPreBuildEventTool"
   8.262 +			/>
   8.263 +			<Tool
   8.264 +				Name="VCCustomBuildTool"
   8.265 +			/>
   8.266 +			<Tool
   8.267 +				Name="VCXMLDataGeneratorTool"
   8.268 +			/>
   8.269 +			<Tool
   8.270 +				Name="VCWebServiceProxyGeneratorTool"
   8.271 +			/>
   8.272 +			<Tool
   8.273 +				Name="VCMIDLTool"
   8.274 +				TargetEnvironment="3"
   8.275 +			/>
   8.276 +			<Tool
   8.277 +				Name="VCCLCompilerTool"
   8.278 +				PreprocessorDefinitions="WIN32;NDEBUG"
   8.279 +				RuntimeLibrary="2"
   8.280 +				UsePrecompiledHeader="0"
   8.281 +				GenerateXMLDocumentationFiles="true"
   8.282 +				WarningLevel="3"
   8.283 +				DebugInformationFormat="3"
   8.284 +			/>
   8.285 +			<Tool
   8.286 +				Name="VCManagedResourceCompilerTool"
   8.287 +			/>
   8.288 +			<Tool
   8.289 +				Name="VCResourceCompilerTool"
   8.290 +			/>
   8.291 +			<Tool
   8.292 +				Name="VCPreLinkEventTool"
   8.293 +			/>
   8.294 +			<Tool
   8.295 +				Name="VCLinkerTool"
   8.296 +				AdditionalDependencies="$(NoInherit)"
   8.297 +				LinkIncremental="1"
   8.298 +				GenerateDebugInformation="true"
   8.299 +				RandomizedBaseAddress="1"
   8.300 +				DataExecutionPrevention="0"
   8.301 +				TargetMachine="17"
   8.302 +			/>
   8.303 +			<Tool
   8.304 +				Name="VCALinkTool"
   8.305 +			/>
   8.306 +			<Tool
   8.307 +				Name="VCManifestTool"
   8.308 +			/>
   8.309 +			<Tool
   8.310 +				Name="VCXDCMakeTool"
   8.311 +			/>
   8.312 +			<Tool
   8.313 +				Name="VCBscMakeTool"
   8.314 +			/>
   8.315 +			<Tool
   8.316 +				Name="VCFxCopTool"
   8.317 +			/>
   8.318 +			<Tool
   8.319 +				Name="VCAppVerifierTool"
   8.320 +			/>
   8.321 +			<Tool
   8.322 +				Name="VCPostBuildEventTool"
   8.323 +			/>
   8.324 +		</Configuration>
   8.325 +	</Configurations>
   8.326 +	<References>
   8.327 +		<AssemblyReference
   8.328 +			RelativePath="System.dll"
   8.329 +			AssemblyName="System, Version=2.0.0.0, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"
   8.330 +			MinFrameworkVersion="131072"
   8.331 +		/>
   8.332 +		<AssemblyReference
   8.333 +			RelativePath="System.Data.dll"
   8.334 +			AssemblyName="System.Data, Version=2.0.0.0, PublicKeyToken=b77a5c561934e089, processorArchitecture=x86"
   8.335 +			MinFrameworkVersion="131072"
   8.336 +		/>
   8.337 +		<AssemblyReference
   8.338 +			RelativePath="System.XML.dll"
   8.339 +			AssemblyName="System.Xml, Version=2.0.0.0, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"
   8.340 +			MinFrameworkVersion="131072"
   8.341 +		/>
   8.342 +	</References>
   8.343 +	<Files>
   8.344 +		<Filter
   8.345 +			Name="Source Files"
   8.346 +			Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
   8.347 +			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
   8.348 +			>
   8.349 +			<File
   8.350 +				RelativePath=".\AssemblyInfo.cpp"
   8.351 +				>
   8.352 +			</File>
   8.353 +			<File
   8.354 +				RelativePath=".\UserAccountControl.cpp"
   8.355 +				>
   8.356 +			</File>
   8.357 +		</Filter>
   8.358 +		<Filter
   8.359 +			Name="Header Files"
   8.360 +			Filter="h;hpp;hxx;hm;inl;inc;xsd"
   8.361 +			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
   8.362 +			>
   8.363 +			<File
   8.364 +				RelativePath=".\UserAccountControl.h"
   8.365 +				>
   8.366 +			</File>
   8.367 +		</Filter>
   8.368 +	</Files>
   8.369 +	<Globals>
   8.370 +	</Globals>
   8.371 +</VisualStudioProject>
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/UacHelpers.CppLibrary/UacHelpers.CppLibrary.vcxproj	Sat Feb 09 17:18:09 2013 +0100
     9.3 @@ -0,0 +1,199 @@
     9.4 +<?xml version="1.0" encoding="utf-8"?>
     9.5 +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
     9.6 +  <ItemGroup Label="ProjectConfigurations">
     9.7 +    <ProjectConfiguration Include="Debug|Win32">
     9.8 +      <Configuration>Debug</Configuration>
     9.9 +      <Platform>Win32</Platform>
    9.10 +    </ProjectConfiguration>
    9.11 +    <ProjectConfiguration Include="Debug|x64">
    9.12 +      <Configuration>Debug</Configuration>
    9.13 +      <Platform>x64</Platform>
    9.14 +    </ProjectConfiguration>
    9.15 +    <ProjectConfiguration Include="Release|Win32">
    9.16 +      <Configuration>Release</Configuration>
    9.17 +      <Platform>Win32</Platform>
    9.18 +    </ProjectConfiguration>
    9.19 +    <ProjectConfiguration Include="Release|x64">
    9.20 +      <Configuration>Release</Configuration>
    9.21 +      <Platform>x64</Platform>
    9.22 +    </ProjectConfiguration>
    9.23 +  </ItemGroup>
    9.24 +  <PropertyGroup Label="Globals">
    9.25 +    <ProjectName>UacHelpers.UserAccountControl</ProjectName>
    9.26 +    <ProjectGuid>{D043A646-FE7A-4334-B23D-E327593C1AE2}</ProjectGuid>
    9.27 +    <RootNamespace>UacHelpersCppLibrary</RootNamespace>
    9.28 +    <SccProjectName>SAK</SccProjectName>
    9.29 +    <SccAuxPath>SAK</SccAuxPath>
    9.30 +    <SccLocalPath>SAK</SccLocalPath>
    9.31 +    <SccProvider>SAK</SccProvider>
    9.32 +    <Keyword>ManagedCProj</Keyword>
    9.33 +  </PropertyGroup>
    9.34 +  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
    9.35 +  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
    9.36 +    <ConfigurationType>DynamicLibrary</ConfigurationType>
    9.37 +    <PlatformToolset>v110</PlatformToolset>
    9.38 +    <CharacterSet>Unicode</CharacterSet>
    9.39 +    <CLRSupport>true</CLRSupport>
    9.40 +    <WholeProgramOptimization>true</WholeProgramOptimization>
    9.41 +  </PropertyGroup>
    9.42 +  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
    9.43 +    <ConfigurationType>DynamicLibrary</ConfigurationType>
    9.44 +    <PlatformToolset>v110</PlatformToolset>
    9.45 +    <CharacterSet>Unicode</CharacterSet>
    9.46 +    <CLRSupport>true</CLRSupport>
    9.47 +  </PropertyGroup>
    9.48 +  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
    9.49 +    <ConfigurationType>DynamicLibrary</ConfigurationType>
    9.50 +    <PlatformToolset>v110</PlatformToolset>
    9.51 +    <CharacterSet>Unicode</CharacterSet>
    9.52 +    <CLRSupport>true</CLRSupport>
    9.53 +    <WholeProgramOptimization>true</WholeProgramOptimization>
    9.54 +  </PropertyGroup>
    9.55 +  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
    9.56 +    <ConfigurationType>DynamicLibrary</ConfigurationType>
    9.57 +    <PlatformToolset>v110</PlatformToolset>
    9.58 +    <CharacterSet>Unicode</CharacterSet>
    9.59 +    <CLRSupport>true</CLRSupport>
    9.60 +  </PropertyGroup>
    9.61 +  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
    9.62 +  <ImportGroup Label="ExtensionSettings">
    9.63 +  </ImportGroup>
    9.64 +  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
    9.65 +    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
    9.66 +  </ImportGroup>
    9.67 +  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
    9.68 +    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
    9.69 +  </ImportGroup>
    9.70 +  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
    9.71 +    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
    9.72 +  </ImportGroup>
    9.73 +  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
    9.74 +    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
    9.75 +  </ImportGroup>
    9.76 +  <PropertyGroup Label="UserMacros" />
    9.77 +  <PropertyGroup>
    9.78 +    <_ProjectFileVersion>11.0.51106.1</_ProjectFileVersion>
    9.79 +  </PropertyGroup>
    9.80 +  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
    9.81 +    <OutDir>..\output\</OutDir>
    9.82 +    <IntDir>$(Configuration)\</IntDir>
    9.83 +    <LinkIncremental>true</LinkIncremental>
    9.84 +  </PropertyGroup>
    9.85 +  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
    9.86 +    <OutDir>..\output\</OutDir>
    9.87 +    <IntDir>$(Platform)\$(Configuration)\</IntDir>
    9.88 +    <LinkIncremental>true</LinkIncremental>
    9.89 +  </PropertyGroup>
    9.90 +  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
    9.91 +    <OutDir>$(SolutionDir)$(Configuration)\</OutDir>
    9.92 +    <IntDir>$(Configuration)\</IntDir>
    9.93 +    <LinkIncremental>false</LinkIncremental>
    9.94 +  </PropertyGroup>
    9.95 +  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
    9.96 +    <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
    9.97 +    <IntDir>$(Platform)\$(Configuration)\</IntDir>
    9.98 +    <LinkIncremental>false</LinkIncremental>
    9.99 +  </PropertyGroup>
   9.100 +  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
   9.101 +    <ClCompile>
   9.102 +      <Optimization>Disabled</Optimization>
   9.103 +      <PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
   9.104 +      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
   9.105 +      <PrecompiledHeader />
   9.106 +      <GenerateXMLDocumentationFiles>true</GenerateXMLDocumentationFiles>
   9.107 +      <WarningLevel>Level3</WarningLevel>
   9.108 +      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
   9.109 +    </ClCompile>
   9.110 +    <Link>
   9.111 +      <AdditionalDependencies />
   9.112 +      <GenerateDebugInformation>true</GenerateDebugInformation>
   9.113 +      <AssemblyDebug>true</AssemblyDebug>
   9.114 +      <RandomizedBaseAddress>false</RandomizedBaseAddress>
   9.115 +      <DataExecutionPrevention />
   9.116 +      <TargetMachine>MachineX86</TargetMachine>
   9.117 +    </Link>
   9.118 +  </ItemDefinitionGroup>
   9.119 +  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
   9.120 +    <Midl>
   9.121 +      <TargetEnvironment>X64</TargetEnvironment>
   9.122 +    </Midl>
   9.123 +    <ClCompile>
   9.124 +      <Optimization>Disabled</Optimization>
   9.125 +      <PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
   9.126 +      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
   9.127 +      <PrecompiledHeader />
   9.128 +      <GenerateXMLDocumentationFiles>true</GenerateXMLDocumentationFiles>
   9.129 +      <WarningLevel>Level3</WarningLevel>
   9.130 +      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
   9.131 +    </ClCompile>
   9.132 +    <Link>
   9.133 +      <AdditionalDependencies />
   9.134 +      <GenerateDebugInformation>true</GenerateDebugInformation>
   9.135 +      <AssemblyDebug>true</AssemblyDebug>
   9.136 +      <RandomizedBaseAddress>false</RandomizedBaseAddress>
   9.137 +      <DataExecutionPrevention />
   9.138 +      <TargetMachine>MachineX64</TargetMachine>
   9.139 +    </Link>
   9.140 +  </ItemDefinitionGroup>
   9.141 +  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
   9.142 +    <ClCompile>
   9.143 +      <PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
   9.144 +      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
   9.145 +      <PrecompiledHeader />
   9.146 +      <GenerateXMLDocumentationFiles>true</GenerateXMLDocumentationFiles>
   9.147 +      <WarningLevel>Level3</WarningLevel>
   9.148 +      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
   9.149 +    </ClCompile>
   9.150 +    <Link>
   9.151 +      <AdditionalDependencies />
   9.152 +      <GenerateDebugInformation>true</GenerateDebugInformation>
   9.153 +      <RandomizedBaseAddress>false</RandomizedBaseAddress>
   9.154 +      <DataExecutionPrevention />
   9.155 +      <TargetMachine>MachineX86</TargetMachine>
   9.156 +    </Link>
   9.157 +  </ItemDefinitionGroup>
   9.158 +  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
   9.159 +    <Midl>
   9.160 +      <TargetEnvironment>X64</TargetEnvironment>
   9.161 +    </Midl>
   9.162 +    <ClCompile>
   9.163 +      <PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
   9.164 +      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
   9.165 +      <PrecompiledHeader />
   9.166 +      <GenerateXMLDocumentationFiles>true</GenerateXMLDocumentationFiles>
   9.167 +      <WarningLevel>Level3</WarningLevel>
   9.168 +      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
   9.169 +    </ClCompile>
   9.170 +    <Link>
   9.171 +      <AdditionalDependencies />
   9.172 +      <GenerateDebugInformation>true</GenerateDebugInformation>
   9.173 +      <RandomizedBaseAddress>false</RandomizedBaseAddress>
   9.174 +      <DataExecutionPrevention />
   9.175 +      <TargetMachine>MachineX64</TargetMachine>
   9.176 +    </Link>
   9.177 +  </ItemDefinitionGroup>
   9.178 +  <ItemGroup>
   9.179 +    <Reference Include="System">
   9.180 +      <CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
   9.181 +      <ReferenceOutputAssembly>true</ReferenceOutputAssembly>
   9.182 +    </Reference>
   9.183 +    <Reference Include="System.Data">
   9.184 +      <CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
   9.185 +      <ReferenceOutputAssembly>true</ReferenceOutputAssembly>
   9.186 +    </Reference>
   9.187 +    <Reference Include="System.Xml">
   9.188 +      <CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
   9.189 +      <ReferenceOutputAssembly>true</ReferenceOutputAssembly>
   9.190 +    </Reference>
   9.191 +  </ItemGroup>
   9.192 +  <ItemGroup>
   9.193 +    <ClCompile Include="AssemblyInfo.cpp" />
   9.194 +    <ClCompile Include="UserAccountControl.cpp" />
   9.195 +  </ItemGroup>
   9.196 +  <ItemGroup>
   9.197 +    <ClInclude Include="UserAccountControl.h" />
   9.198 +  </ItemGroup>
   9.199 +  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   9.200 +  <ImportGroup Label="ExtensionTargets">
   9.201 +  </ImportGroup>
   9.202 +</Project>
   9.203 \ No newline at end of file
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/UacHelpers.CppLibrary/UserAccountControl.cpp	Sat Feb 09 17:18:09 2013 +0100
    10.3 @@ -0,0 +1,226 @@
    10.4 +#include "UserAccountControl.h"
    10.5 +
    10.6 +#include <windows.h>
    10.7 +#pragma comment (lib, "kernel32.lib")
    10.8 +#pragma comment (lib, "advapi32.lib")
    10.9 +
   10.10 +#include <vcclr.h>
   10.11 +#include <msclr\marshal.h>
   10.12 +#include <msclr\marshal_windows.h>
   10.13 +
   10.14 +using namespace msclr::interop;
   10.15 +
   10.16 +using namespace System::ComponentModel;
   10.17 +using namespace Microsoft::Win32;
   10.18 +
   10.19 +namespace UacHelpers {
   10.20 +
   10.21 +	Process^ UserAccountControl::CreateProcessAsAdmin(System::String^ exePath, System::String^ arguments)
   10.22 +    {
   10.23 +        ProcessStartInfo^ psi = gcnew ProcessStartInfo(exePath, arguments);
   10.24 +        psi->UseShellExecute = true;
   10.25 +        psi->Verb = "runas";
   10.26 +		return Process::Start(psi);
   10.27 +    }
   10.28 +
   10.29 +	Process^ UserAccountControl::CreateProcessAsStandardUser(System::String^ exePath, System::String^ arguments)
   10.30 +	{
   10.31 +		marshal_context context;
   10.32 +
   10.33 +		//If the current process is not elevated, then there's no reason to go through the hassle --
   10.34 +		//just use the standard System.Diagnostics.Process facilities.
   10.35 +		if (!IsCurrentProcessElevated)
   10.36 +		{
   10.37 +			return Process::Start(exePath, arguments);
   10.38 +		}
   10.39 +
   10.40 +		//The following implementation is roughly based on Aaron Margosis' post:
   10.41 +		//http://blogs.msdn.com/aaron_margosis/archive/2009/06/06/faq-how-do-i-start-a-program-as-the-desktop-user-from-an-elevated-app.aspx
   10.42 +
   10.43 +		//Enable SeIncreaseQuotaPrivilege in this process.  (This requires administrative privileges.)
   10.44 +		HANDLE hProcessToken = NULL;
   10.45 +		if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &hProcessToken))
   10.46 +		{
   10.47 +			throw gcnew Win32Exception(GetLastError());
   10.48 +		}
   10.49 +		else
   10.50 +		{
   10.51 +			TOKEN_PRIVILEGES tkp;
   10.52 +			tkp.PrivilegeCount = 1;
   10.53 +			LookupPrivilegeValueW(NULL, SE_INCREASE_QUOTA_NAME, &tkp.Privileges[0].Luid);
   10.54 +			tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
   10.55 +			AdjustTokenPrivileges(hProcessToken, FALSE, &tkp, 0, NULL, NULL);
   10.56 +			DWORD dwLastErr = GetLastError();
   10.57 +			CloseHandle(hProcessToken);
   10.58 +			if (ERROR_SUCCESS != dwLastErr)
   10.59 +			{
   10.60 +				throw gcnew Win32Exception(dwLastErr);
   10.61 +			}
   10.62 +		}
   10.63 +
   10.64 +		//Get window handle representing the desktop shell.  This might not work if there is no shell window, or when
   10.65 +		//using a custom shell.  Also note that we're assuming that the shell is not running elevated.
   10.66 +		HWND hShellWnd = GetShellWindow();
   10.67 +		if (hShellWnd == NULL)
   10.68 +		{
   10.69 +			throw gcnew System::InvalidOperationException("Unable to locate shell window; you might be using a custom shell");
   10.70 +		}
   10.71 +
   10.72 +		//Get the ID of the desktop shell process.
   10.73 +		DWORD dwShellPID;
   10.74 +		GetWindowThreadProcessId(hShellWnd, &dwShellPID);
   10.75 +		if (dwShellPID == 0)
   10.76 +		{
   10.77 +			throw gcnew Win32Exception(GetLastError());
   10.78 +		}
   10.79 +
   10.80 +		//Open the desktop shell process in order to get the process token.
   10.81 +		HANDLE hShellProcess = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, dwShellPID);
   10.82 +		if (hShellProcess == NULL)
   10.83 +		{
   10.84 +			throw gcnew Win32Exception(GetLastError());
   10.85 +		}
   10.86 +
   10.87 +		HANDLE hShellProcessToken = NULL;
   10.88 +		HANDLE hPrimaryToken = NULL;
   10.89 +		try
   10.90 +		{
   10.91 +			//Get the process token of the desktop shell.
   10.92 +			if (!OpenProcessToken(hShellProcess, TOKEN_DUPLICATE, &hShellProcessToken))
   10.93 +			{
   10.94 +				throw gcnew Win32Exception(GetLastError());
   10.95 +			}
   10.96 +
   10.97 +			//Duplicate the shell's process token to get a primary token.
   10.98 +			const DWORD dwTokenRights = TOKEN_QUERY | TOKEN_ASSIGN_PRIMARY | TOKEN_DUPLICATE | TOKEN_ADJUST_DEFAULT | TOKEN_ADJUST_SESSIONID;
   10.99 +			if (!DuplicateTokenEx(hShellProcessToken, dwTokenRights, NULL, SecurityImpersonation, TokenPrimary, &hPrimaryToken))
  10.100 +			{
  10.101 +				throw gcnew Win32Exception(GetLastError());
  10.102 +			}
  10.103 +
  10.104 +			//Start the target process with the new token.
  10.105 +			STARTUPINFO si = {0}; si.cb = sizeof(si);
  10.106 +			PROCESS_INFORMATION pi = {0};
  10.107 +			if (!CreateProcessWithTokenW(hPrimaryToken, 0,
  10.108 +				context.marshal_as<LPCWSTR>(exePath), context.marshal_as<LPWSTR>(exePath + " " + arguments),
  10.109 +				0, NULL, NULL, &si, &pi))
  10.110 +			{
  10.111 +				throw gcnew Win32Exception(GetLastError());
  10.112 +			}
  10.113 +			CloseHandle(pi.hProcess);
  10.114 +			CloseHandle(pi.hThread);
  10.115 +
  10.116 +			return Process::GetProcessById(pi.dwProcessId);
  10.117 +		}
  10.118 +		finally
  10.119 +		{
  10.120 +			if (hShellProcessToken != NULL)
  10.121 +				CloseHandle(hShellProcessToken);
  10.122 +
  10.123 +			if (hPrimaryToken != NULL)
  10.124 +				CloseHandle(hPrimaryToken);
  10.125 +
  10.126 +			if (hShellProcess != NULL)
  10.127 +				CloseHandle(hShellProcess);
  10.128 +		}
  10.129 +	}
  10.130 +
  10.131 +	bool UserAccountControl::IsUserAdmin::get()
  10.132 +	{
  10.133 +		if (UserAccountControl::IsUacEnabled)
  10.134 +			return GetProcessTokenElevationType() != TokenElevationTypeDefault;	//split token
  10.135 +
  10.136 +		//If UAC is off, we can't rely on the token; check for Admin group.
  10.137 +		return WindowsPrincipal(WindowsIdentity::GetCurrent()).IsInRole("Administrators");
  10.138 +	}
  10.139 +
  10.140 +	bool UserAccountControl::IsUacEnabled::get()
  10.141 +	{
  10.142 +		//Check the HKLM\Software\Microsoft\Windows\CurrentVersion\Policies\System\EnableLUA registry value.
  10.143 +		RegistryKey^ key = Registry::LocalMachine->OpenSubKey(UacRegistryKey, false);
  10.144 +		return key->GetValue(UacRegistryValue)->Equals(1);
  10.145 +    }
  10.146 +
  10.147 +	void UserAccountControl::DisableUac()
  10.148 +	{
  10.149 +		SetUacRegistryValue(false);
  10.150 +	}
  10.151 +
  10.152 +	void UserAccountControl::DisableUacAndRestartWindows()
  10.153 +	{
  10.154 +		DisableUac();
  10.155 +		RestartWindows();
  10.156 +	}
  10.157 +
  10.158 +	void UserAccountControl::EnableUac()
  10.159 +	{
  10.160 +		SetUacRegistryValue(true);
  10.161 +	}
  10.162 +
  10.163 +	void UserAccountControl::EnableUacAndRestartWindows()
  10.164 +	{
  10.165 +		EnableUac();
  10.166 +		RestartWindows();
  10.167 +	}
  10.168 +
  10.169 +	bool UserAccountControl::IsCurrentProcessElevated::get()
  10.170 +	{
  10.171 +		return GetProcessTokenElevationType() == TokenElevationTypeFull;	//elevated
  10.172 +	}
  10.173 +
  10.174 +	bool UserAccountControl::IsCurrentProcessVirtualized::get()
  10.175 +	{
  10.176 +		HANDLE hToken;
  10.177 +        try
  10.178 +        {
  10.179 +            if (!OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &hToken))
  10.180 +				throw gcnew Win32Exception(GetLastError());
  10.181 +
  10.182 +            DWORD virtualizationEnabled;
  10.183 +			DWORD dwSize;
  10.184 +			if (!GetTokenInformation(hToken, TokenVirtualizationEnabled, &virtualizationEnabled, sizeof(virtualizationEnabled), &dwSize))
  10.185 +                throw gcnew Win32Exception(GetLastError());
  10.186 +
  10.187 +			return virtualizationEnabled != 0;
  10.188 +        }
  10.189 +        finally
  10.190 +        {
  10.191 +            CloseHandle(hToken);
  10.192 +        }
  10.193 +	}
  10.194 +
  10.195 +	int UserAccountControl::GetProcessTokenElevationType()
  10.196 +	{
  10.197 +		HANDLE hToken;
  10.198 +        try
  10.199 +        {
  10.200 +            if (!OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &hToken))
  10.201 +				throw gcnew Win32Exception(GetLastError());
  10.202 +
  10.203 +            TOKEN_ELEVATION_TYPE elevationType;
  10.204 +			DWORD dwSize;
  10.205 +            if (!GetTokenInformation(hToken, TokenElevationType, &elevationType, sizeof(elevationType), &dwSize))
  10.206 +                throw gcnew Win32Exception(GetLastError());
  10.207 +
  10.208 +			return elevationType;
  10.209 +        }
  10.210 +        finally
  10.211 +        {
  10.212 +            CloseHandle(hToken);
  10.213 +        }
  10.214 +	}
  10.215 +
  10.216 +	void UserAccountControl::SetUacRegistryValue(bool enabled)
  10.217 +	{
  10.218 +		RegistryKey^ key = Registry::LocalMachine->OpenSubKey(UacRegistryKey, true);
  10.219 +		key->SetValue(UacRegistryValue, enabled ? 1 : 0);
  10.220 +	}
  10.221 +
  10.222 +	void UserAccountControl::RestartWindows()
  10.223 +	{
  10.224 +		InitiateSystemShutdownEx(NULL, NULL, 0/*Timeout*/,
  10.225 +								 TRUE/*ForceAppsClosed*/, TRUE/*RebootAfterShutdown*/,
  10.226 +								 SHTDN_REASON_MAJOR_OPERATINGSYSTEM | SHTDN_REASON_MINOR_RECONFIG | SHTDN_REASON_FLAG_PLANNED);
  10.227 +		//This shutdown flag corresponds to: "Operating System: Reconfiguration (Planned)".
  10.228 +	}
  10.229 +}
  10.230 \ No newline at end of file
    11.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2 +++ b/UacHelpers.CppLibrary/UserAccountControl.h	Sat Feb 09 17:18:09 2013 +0100
    11.3 @@ -0,0 +1,133 @@
    11.4 +// UacHelpers.CppLibrary.h
    11.5 +
    11.6 +#pragma once
    11.7 +
    11.8 +using namespace System::Diagnostics;
    11.9 +using namespace System::Security::Principal;
   11.10 +
   11.11 +namespace UacHelpers {
   11.12 +
   11.13 +	///<summary>
   11.14 +	///Provides facilities for enabling and disabling User Account Control (UAC),
   11.15 +	///determining elevation and virtualization status, and launching a process
   11.16 +	///under elevated credentials.
   11.17 +	///</summary>
   11.18 +	///<remarks>
   11.19 +	///Note that there's a delicate scenario where the registry key has already been
   11.20 +	///changed, but the user has not logged off yet so the token hasn't been filtered.
   11.21 +	///In that case, we will think that UAC is on but the user is not an admin (because
   11.22 +	///the token is not a split token).
   11.23 +	///</remarks>
   11.24 +	public ref class UserAccountControl abstract sealed
   11.25 +	{
   11.26 +	public:
   11.27 +		///<summary>
   11.28 +		///Returns <b>true</b> if the current user has administrator privileges.
   11.29 +		///</summary>
   11.30 +		///<remarks>
   11.31 +		///If UAC is on, then this property will return <b>true</b> even if the
   11.32 +		///current process is not running elevated.  If UAC is off, then this
   11.33 +		///property will return <b>true</b> if the user is part of the built-in
   11.34 +		///<i>Administrators</i> group.
   11.35 +		///</remarks>
   11.36 +		static property bool IsUserAdmin
   11.37 +        {
   11.38 +            bool get();
   11.39 +        }
   11.40 +
   11.41 +		///<summary>
   11.42 +		///Returns <b>true</b> if User Account Control (UAC) is enabled on
   11.43 +		///this machine.
   11.44 +		///</summary>
   11.45 +		///<remarks>
   11.46 +		///This value is obtained by checking the LUA registry key.  It is possible
   11.47 +		///that the user has not restarted the machine after enabling/disabling UAC.
   11.48 +		///In that case, the value of the registry key does not reflect the true state
   11.49 +		///of affairs.  It is possible to devise a custom solution that would provide
   11.50 +		///a mechanism for tracking whether a restart occurred since UAC settings were
   11.51 +		///changed (using the RunOnce mechanism, temporary files, or volatile registry keys).
   11.52 +		///</remarks>
   11.53 +		static property bool IsUacEnabled
   11.54 +        {
   11.55 +            bool get();
   11.56 +        }
   11.57 +
   11.58 +		///<summary>
   11.59 +		///Returns <b>true</b> if the current process is using UAC virtualization.
   11.60 +		///</summary>
   11.61 +		///<remarks>
   11.62 +		///Under UAC virtualization, file system and registry accesses to specific
   11.63 +		///locations performed by an application are redirected to provide backwards-
   11.64 +		///compatibility.  64-bit applications or applications that have an associated
   11.65 +		///manifest do not enjoy UAC virtualization because they are assumed to be
   11.66 +		///compatible with Vista and UAC.
   11.67 +		///</remarks>
   11.68 +        static property bool IsCurrentProcessVirtualized
   11.69 +        {
   11.70 +            bool get();
   11.71 +        }
   11.72 +
   11.73 +		///<summary>
   11.74 +		///Returns <b>true</b> if the current process is elevated, i.e. if the process
   11.75 +		///went through an elevation consent phase.
   11.76 +		///</summary>
   11.77 +		///<remarks>
   11.78 +		///This property will return <b>false</b> if UAC is disabled and the process
   11.79 +		///is running as admin.  It only determines whether the process went through
   11.80 +		///the elevation procedure.
   11.81 +		///</remarks>
   11.82 +		static property bool IsCurrentProcessElevated
   11.83 +        {
   11.84 +            bool get();
   11.85 +        }
   11.86 +
   11.87 +		///<summary>
   11.88 +		///Disables User Account Control by changing the LUA registry key.
   11.89 +		///The changes do not have effect until the system is restarted.
   11.90 +		///</summary>
   11.91 +		static void DisableUac();
   11.92 +		
   11.93 +		///<summary>
   11.94 +		///Disables User Account Control and restarts the system.
   11.95 +		///</summary>
   11.96 +		static void DisableUacAndRestartWindows();
   11.97 +
   11.98 +		///<summary>
   11.99 +		///Enables User Account Control by changing the LUA registry key.
  11.100 +		///The changes do not have effect until the system is restarted.
  11.101 +		///</summary>
  11.102 +		static void EnableUac();
  11.103 +
  11.104 +		///<summary>
  11.105 +		///Enables User Account Control and restarts the system.
  11.106 +		///</summary>
  11.107 +		static void EnableUacAndRestartWindows();
  11.108 +
  11.109 +		///<summary>
  11.110 +		///Creates a process under the elevated token, regardless of UAC settings
  11.111 +		///or the manifest associated with that process.
  11.112 +		///</summary>
  11.113 +		///<param name="exePath">The path to the executable file.</param>
  11.114 +		///<param name="arguments">The command-line arguments to pass to the process.</param>
  11.115 +		///<returns>A <see cref="Process"/> object representing the newly created process.</returns>
  11.116 +		static Process^ CreateProcessAsAdmin(System::String^ exePath, System::String^ arguments);
  11.117 +
  11.118 +		///<summary>
  11.119 +		///Creates a process under the standard user if the current process is elevated.  The identity
  11.120 +		///of the standard user is determined by retrieving the user token of the currently running Explorer
  11.121 +		//(shell) process.  If the current process is not elevated, the standard user is used.
  11.122 +		///</summary>
  11.123 +		///<param name="exePath">The path to the executable file.</param>
  11.124 +		///<param name="arguments">The command-line arguments to pass to the process.</param>
  11.125 +		///<returns>A <see cref="Process"/> object representing the newly created process.</returns>
  11.126 +		static Process^ CreateProcessAsStandardUser(System::String^ exePath, System::String^ arguments);
  11.127 +
  11.128 +	private:
  11.129 +		static int GetProcessTokenElevationType();
  11.130 +		static void SetUacRegistryValue(bool enable);
  11.131 +		static void RestartWindows();
  11.132 +
  11.133 +		static System::String^ UacRegistryKey = "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System";
  11.134 +		static System::String^ UacRegistryValue = "EnableLUA";
  11.135 +	};
  11.136 +}	// end namespace UacHelpers
  11.137 \ No newline at end of file