public static bool IsGenuineWindows()
        {
            bool _IsGenuineWindows = false;
            Guid ApplicationID     = new Guid("55c92734-d682-4d71-983e-d6ec3f16059f");   //Application ID GUID http://technet.microsoft.com/en-us/library/dd772270.aspx
            SLID windowsSlid       = (Guid)ApplicationID;

            try
            {
                SL_GENUINE_STATE genuineState = SL_GENUINE_STATE.SL_GEN_STATE_LAST;
                uint             ResultInt    = SLIsGenuineLocal(ref windowsSlid, ref genuineState, IntPtr.Zero);
                if (ResultInt == 0)
                {
                    _IsGenuineWindows = (genuineState == SL_GENUINE_STATE.SL_GEN_STATE_IS_GENUINE);
                }
                else
                {
                    Console.WriteLine("Error getting information {0}", ResultInt.ToString());
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            return(_IsGenuineWindows);
        }
Exemplo n.º 2
0
        public static bool IsGenuineWindows()
        {
            bool _IsGenuineWindows = false;
            Guid ApplicationID     = new Guid("55c92734-d682-4d71-983e-d6ec3f16059f");
            SLID windowsSlid       = (Guid)ApplicationID;

            try
            {
                SL_GENUINE_STATE genuineState = SL_GENUINE_STATE.SL_GEN_STATE_LAST;
                uint             ResultInt    = SLIsGenuineLocal(ref windowsSlid, ref genuineState, IntPtr.Zero);
                if (ResultInt == 0)
                {
                    _IsGenuineWindows = (genuineState == SL_GENUINE_STATE.SL_GEN_STATE_IS_GENUINE);
                }
                else
                {
                    throw new Exception("Error getting information {0}", ResultInt.ToString());
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

            return(_IsGenuineWindows);
        }
 internal static extern uint SLIsGenuineLocal(ref SLID slid, [In, Out] ref SL_GENUINE_STATE genuineState, IntPtr val3);