Exemple #1
0
        /// <summary>
        /// 是否特殊目录接受UAC控制
        /// </summary>
        /// <returns></returns>
        public bool IsUAC()
        {
            #region 判断当前系统

            //获取系统信息
            System.OperatingSystem osInfo = System.Environment.OSVersion;
            ////获取操作系统ID
            System.PlatformID platformID = osInfo.Platform;
            //获取主版本号
            int versionMajor = osInfo.Version.Major;
            //获取副版本号
            int versionMinor = osInfo.Version.Minor;

            #endregion

            string curWorkPath = Environment.CurrentDirectory;

            if (versionMajor == 6 && versionMinor == 1 && curWorkPath.Contains("Program Files"))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
 internal static bool IsUnix()
 {
     System.PlatformID platform = System.Environment.OSVersion.Platform;
     return(platform == System.PlatformID.MacOSX ||
            platform == System.PlatformID.Unix ||
            (int)platform == 128);
 }
Exemple #3
0
        public static Alt.PlatformID ToPlatformID(System.PlatformID src)
        {
            switch (src)
            {
            case System.PlatformID.Win32S:
                return(Alt.PlatformID.Win32S);

            case System.PlatformID.Win32Windows:
                return(Alt.PlatformID.Win32Windows);

            case System.PlatformID.Win32NT:
                return(Alt.PlatformID.Win32NT);

            case System.PlatformID.WinCE:
                return(Alt.PlatformID.WinCE);

            case System.PlatformID.Unix:
                return(Alt.PlatformID.Unix);

            case System.PlatformID.Xbox:
                return(Alt.PlatformID.Xbox);

            case System.PlatformID.MacOSX:
                return(Alt.PlatformID.MacOSX);
            }

            return(Alt.PlatformID.Unknown);
        }
Exemple #4
0
 public static bool IsWindows()
 {
     System.PlatformID p = GetPlatformID();
     return((p == PlatformID.Win32NT) ||
            (p == PlatformID.Win32Windows) ||
            (p == PlatformID.Win32S) ||
            (p == PlatformID.WinCE));
 }
        // Only tested for one 64 bit Windows7 PC, not other operating systems
        public static bool IsWindows7()
        {
            System.OperatingSystem osInfo   = System.Environment.OSVersion;
            System.PlatformID      platform = osInfo.Platform;
            int majorVersion = osInfo.Version.Major;
            int minorVersion = osInfo.Version.Minor;

            return((platform == System.PlatformID.Win32NT) && (majorVersion == 6) && (minorVersion >= 1));
        }
Exemple #6
0
        /// <summary>
        /// 数据库工厂构造函数
        /// </summary>
        /// <param name="dbtype">数据库枚举</param>
        static DataHelper()
        {
            var loggerFactory = new LoggerFactory();
            Func <string, LogLevel, bool> filter = (category, level) => true;

            loggerFactory.AddProvider(new DebugLoggerProvider(filter));
            Log = loggerFactory.CreateLogger(DATALOGSOURCE);
            try
            {
                System.OperatingSystem osInfo     = System.Environment.OSVersion;
                System.PlatformID      platformID = osInfo.Platform;
                if (platformID.Equals(PlatformID.Unix))
                {
                    Console.WriteLine("GateWay Is Running in Unix");
                    CFGPATH = @"/home/pi/scada/host.cfg";
                    INIPATH = @"/home/pi/scada/host.ini";
                }
                if (platformID.Equals(PlatformID.Win32NT))
                {
                    Console.WriteLine("GateWay Is Running in Win32NT");
                    CFGPATH = @"C:\DataConfig\host.cfg";
                    INIPATH = @"C:\DataConfig\host.ini";
                }

                if (File.Exists(INIPATH))
                {
                    var builder = new ConfigurationBuilder();
                    var ibuild  = builder.AddIniFile(INIPATH);
                    var root    = ibuild.Build();
                    var host    = root.GetSection("HOST");
                    m_host = host.GetSection("SERVER").Value;
                    var db = root.GetSection("DATABASE");
                    m_ConnStr = db.GetSection("CONNSTRING").Value;
                    m_Path    = db.GetSection("ARCHIVE").Value;
                    m_type    = db.GetSection("TYPE").Value;
                }
                else if (File.Exists(CFGPATH))
                {
                    using (StreamReader objReader = new StreamReader(CFGPATH))
                    {
                        m_host    = objReader.ReadLine();
                        m_ConnStr = objReader.ReadLine();
                        m_Path    = objReader.ReadLine();
                    }
                }
                IPAddress addr;
                if (string.IsNullOrEmpty(m_host) || !IPAddress.TryParse(m_host, out addr))
                {
                    m_host = Environment.MachineName;
                }
                _ins = new MysqlFactory();
            }
            catch (Exception e)
            {
                AddErrorLog(e);
            }
        }
Exemple #7
0
    {   // 获取操作系统ID
        public static System.PlatformID GetPlatformID()
        {
            //获取系统信息
            System.OperatingSystem osInfo = System.Environment.OSVersion;

            //获取操作系统ID
            System.PlatformID platformID = osInfo.Platform;

            return(platformID);
        }
Exemple #8
0
 static void Main(string[] args)
 {
     //获取系统信息
     System.OperatingSystem osInfo = System.Environment.OSVersion;
     //获取操作系统ID
     System.PlatformID platformID = osInfo.Platform;
     //获取主版本号
     int versionMajor = osInfo.Version.Major;
     //获取副版本号
     int versionMinor = osInfo.Version.Minor;
 }
Exemple #9
0
        private void Form1_Load(object sender, EventArgs e)
        {
            this.FormBorderStyle = FormBorderStyle.FixedSingle;

            string path;

            platID = System.Environment.OSVersion.Platform;

            if (platID == PlatformID.WinCE)
            {
                path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);
            }
            else
            {
                path = System.IO.Directory.GetCurrentDirectory();
            }

            if (System.IO.File.Exists(path + "\\0.rpg") == false)
            {
                MessageBoxButtons       MBB  = MessageBoxButtons.OK;
                MessageBoxIcon          MBI  = MessageBoxIcon.Hand;
                MessageBoxDefaultButton MBDB = MessageBoxDefaultButton.Button1;
                MessageBox.Show("请将本程序放入仙剑奇侠传Dos版的安装目录中运行, 谢谢! :)", "提示", MBB, MBI, MBDB);

                System.Windows.Forms.Application.Exit();
                return;
            }

            checkBoxSaveTime.Checked = false;
            checkBoxGoods.Checked    = false;

            this.MaximizeBox          = false;
            tabControl1.Visible       = false;
            menuItemSave.Enabled      = false;
            textBoxMoney.MaxLength    = 7;
            textBoxCalabash.MaxLength = 2;
            textBoxSaveTime.MaxLength = 4;

            comboBox1.SelectedIndex = 0;

            textBoxHp.MaxLength      = 3; //max hp, mp 999
            textBoxMaxHp.MaxLength   = 3;
            textBoxMp.MaxLength      = 3;
            textBoxMaxMp.MaxLength   = 3;
            textBoxExp.MaxLength     = 5; //max exp 32000
            textBoxNowRank.MaxLength = 2; //max now_rank 99
            textBoxPower.MaxLength   = 4; // max 5000
            textBoxWakan.MaxLength   = 4;
            textBoxDefence.MaxLength = 4;
            textBoxSpeed.MaxLength   = 4;
            textBoxLuck.MaxLength    = 4;
            buttonGoods.Enabled      = false;
        }
Exemple #10
0
        public static int GetOSVersionMajorNum()
        {
            //判断
            string iniPath = Environment.GetFolderPath(Environment.SpecialFolder.System);

            //获取系统信息
            System.OperatingSystem osInfo = System.Environment.OSVersion;
            //获取操作系统ID
            System.PlatformID platformID = osInfo.Platform;
            //获取主版本号
            int versionMajor = osInfo.Version.Major;

            return(versionMajor);
        }
Exemple #11
0
        public static PlatformFlavor GetPlatformFlavor()
        {
            System.PlatformID platform = GetPlatform();

            if (platform == PlatformID.Win32NT)
            {
                return(PlatformFlavor.Windows);
            }
            else if (platform == PlatformID.Unix)
            {
                if (System.IO.File.Exists("/etc/issue"))
                {
                    string issueText = System.IO.File.ReadAllText("/etc/issue");

                    if (issueText.Contains("CentOS"))
                    {
                        return(PlatformFlavor.CentOS);
                    }
                    else if (issueText.Contains("SUSE Linux Enterprise"))
                    {
                        return(PlatformFlavor.SLES);
                    }
                    else if (issueText.Contains("Ubuntu"))
                    {
                        return(PlatformFlavor.Ubuntu);
                    }
                    else if (issueText.Contains("openSUSE"))
                    {
                        return(PlatformFlavor.OpenSUSE);
                    }
                    else
                    {
                        return(PlatformFlavor.UnknownUnix);
                    }
                }
                else
                {
                    return(PlatformFlavor.UnknownUnix);
                }
            }
            else if (platform == PlatformID.MacOSX)
            {
                return(PlatformFlavor.OSX);
            }
            else
            {
                return(PlatformFlavor.Unknown);
            }
        }
Exemple #12
0
        private void MainForm_Load(object sender, EventArgs e)
        {

            LibMPlayerCommon.BackendPrograms b = new LibMPlayerCommon.BackendPrograms();
            if (System.IO.File.Exists(MediaPlayer.Properties.Settings.Default.MPlayerPath) == false
                && System.IO.File.Exists(b.MPlayer) == false && BackendPrograms.OSPlatform() == "windows")
            {
                MessageBox.Show("Cannot find mplayer.  Loading properties form to select.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                btnPlayerProperties_Click(sender, e);
            }


            MplayerBackends backend;
            System.PlatformID runningPlatform = System.Environment.OSVersion.Platform;
            if (runningPlatform == System.PlatformID.Unix)
            {
                backend = MplayerBackends.GL2;
            }
            else if (runningPlatform == PlatformID.MacOSX)
            {
                backend = MplayerBackends.OpenGL;
            }
            else
            {
                backend = MplayerBackends.Direct3D;
            }


            this._play = new MPlayer(panelVideo.Handle.ToInt32(), backend, MediaPlayer.Properties.Settings.Default.MPlayerPath);
            this._play.VideoExited += new MplayerEventHandler(play_VideoExited);
            this._play.CurrentPosition += new MplayerEventHandler(_play_CurrentPosition);


            // Set fullscreen
            if (_fullscreen == true && (this.WindowState != FormWindowState.Maximized))
            {
                this.ToggleFormFullScreen();
            }

            // start playing mmediately
            if (_playNow == true && this._filePath != "")
            {
                btnPlay_Click(new object(), new EventArgs());
            }

        }
Exemple #13
0
        //获取系统路径
        public string getSystemVersion()
        {
            //获取系统信息
            System.OperatingSystem osInfo = System.Environment.OSVersion;
            //获取操作系统ID
            System.PlatformID platformID = osInfo.Platform;
            //获取主版本号
            int versionMajor = osInfo.Version.Major;
            //获取副版本号
            int versionMinor = osInfo.Version.Minor;

            switch (versionMajor)
            {
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
                if (versionMinor == 0)
                {
                    return("win2k");
                }
                return("winxp");

            case 6:
                switch (versionMinor)
                {
                case 0:
                    return("vista");

                case 1:
                    return("win7");

                case 2:
                    return("win8");

                case 3:
                    return("win8.1");
                }
                return("未知版本");

            default:
                return("未知版本");
            }
        }
        public OperatingSystem(PlatformID platform, Version version)
        {
            if (version == null)
            {
                throw new ArgumentNullException("version");
            }

            _platform = platform;
            _version  = version;

            if (platform == PlatformID.Win32NT)
            {
                // The service pack is encoded in the upper bits of the revision
                if (version.Revision != 0)
                {
                    _servicePack = "Service Pack " + (version.Revision >> 16);
                }
            }
        }
Exemple #15
0
 /// <summary>
 /// 取当前电脑的系统
 /// </summary>
 /// <param name="version">系统版本号</param>
 /// <returns>当前电脑的系统</returns>
 public static string GetSystemVersion(ref string version)
 {
     try
     {
         Hashtable table = new Hashtable();
         table.Add("140", "Windows95");
         table.Add("1410", "Windows98");
         table.Add("1490", "WindowsMe");
         table.Add("230", "WindowsNT35");
         table.Add("240", "WindowsNT40");
         table.Add("250", "Windows2000");
         table.Add("251", "WindowsXP");
         table.Add("252", "Windows2003");
         table.Add("260", "WindowsVista");
         table.Add("261", "Windows7");
         table.Add("271", "Windows8");
         //获取系统信息
         System.OperatingSystem osInfo = System.Environment.OSVersion;
         //获取操作系统ID
         System.PlatformID platformID = osInfo.Platform;
         //获取主版本号
         int versionMajor = osInfo.Version.Major;
         //获取副版本号
         int versionMinor = osInfo.Version.Minor;
         version = versionMajor + "." + versionMinor;
         string osInfor = platformID.GetHashCode().ToString() + versionMajor.ToString() + versionMinor.ToString();
         if (table.ContainsKey(osInfor))
         {
             return(table[osInfor].ToString());
         }
         else
         {
             return(osInfor);
         }
     }
     catch
     {
         version = "0.0";
         return("未知系统");
     }
 }
Exemple #16
0
    // EFFECTS: Checks the OS Version and sets the deliminator between paths
    // MODIFIES: nothing
    // REQUIRES: nothing
    public static OSVersion GetOSVersion()
    {
        System.OperatingSystem os  = System.Environment.OSVersion;
        System.PlatformID      pid = os.Platform;

        switch (pid)
        {
        case System.PlatformID.Win32NT:
        case System.PlatformID.Win32S:
        case System.PlatformID.Win32Windows:
        case System.PlatformID.WinCE:
            return(OSVersion.Windows);

        case System.PlatformID.Unix:
        case System.PlatformID.MacOSX:
            return(OSVersion.MacOSX);

        default:
            return(OSVersion.Invalid);
        }
    }
Exemple #17
0
        public MPlayerImplementation()
        {
            MplayerBackends backend;

            System.PlatformID runningPlatform = System.Environment.OSVersion.Platform;
            if (runningPlatform == System.PlatformID.Unix)
            {
                backend = MplayerBackends.GL2;
            }
            else if (runningPlatform == PlatformID.MacOSX)
            {
                backend = MplayerBackends.OpenGL;
            }
            else
            {
                backend = MplayerBackends.Direct3D;
            }
            player                  = new MPlayer(0, backend);
            player.Finalfile       += Player_Finalfile;
            player.MplayerError    += Player_MplayerError;
            player.CurrentPosition += Player_CurrentPosition;
        }
Exemple #18
0
 static Configuration()
 {
     System.PlatformID PID = System.Environment.OSVersion.Platform;
     MS = (PID == PlatformID.Win32NT) || (PID == PlatformID.WinCE) || (PID == PlatformID.Win32Windows) || (PID == PlatformID.Win32S);
 }
Exemple #19
0
        public static void Open()
        {
            System.PlatformID p = Environment.OSVersion.Platform;

            // try loading shipped kernel drivers on Unix
            // (will probably only work on Linux through)
            if (p == PlatformID.Unix)
            {
                // try loading the `msr` kernel module on Linux (required on ost kernels)
                Process modprobe = new Process();
                try {
                    modprobe.StartInfo.FileName  = "modprobe";
                    modprobe.StartInfo.Arguments = "msr";
                    modprobe.Start();
                    modprobe.WaitForExit();
                } catch (Exception e) {
                    report.AppendLine(string.Format("Failed to load `msr` kernel driver: {0}", e.Message));
                }

                return;
            }

            // following code is Windows NT only
            if ((p != PlatformID.Win32NT) && (p != PlatformID.WinCE))
            {
                return;
            }

            if (driver != null)
            {
                return;
            }

            // clear the current report
            report.Length = 0;

            InitializeKernelDriver();

            if (!driver.IsOpen)
            {
                // driver is not loaded, try to install and open
                InstallKernelDriverCore(
                    Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
            }

            if (!driver.IsOpen)
            {
                driver = null;
            }

            string mutexName = "Global\\Access_ISABUS.HTP.Method";

            try
            {
                isaBusMutex = new Mutex(false, mutexName);
            }
            catch (UnauthorizedAccessException)
            {
                try
                {
                    isaBusMutex = Mutex.OpenExisting(mutexName, MutexRights.Synchronize);
                }
                catch { }
            }
        }
 public static PlatformID getOSPlatformID()
 {
     //获取操作系统ID
     System.PlatformID platformID = osInfo.Platform;
     return(platformID);
 }
Exemple #21
0
        public static System.Version GetReleaseVersion()
        {
            System.PlatformID platform = GetPlatform();
            PlatformFlavor    flavor   = GetPlatformFlavor();

            if (platform == PlatformID.Win32NT)
            {
                return(System.Environment.OSVersion.Version);
            }
            else if (platform == PlatformID.Unix)
            {
                if (flavor == PlatformFlavor.CentOS)
                {
                    if (System.IO.File.Exists("/etc/issue"))
                    {
                        string issueText     = System.IO.File.ReadAllText("/etc/issue");
                        var    versionString = Regex.Match(issueText, "[0-9].[0-9]{1,2}");
                        if (versionString.Success)
                        {
                            return(new System.Version(versionString.Value));
                        }
                        else
                        {
                            return(new System.Version(0, 0));
                        }
                    }
                    else
                    {
                        throw new Exception("No /etc/issue file for Flavor CentOS");
                    }
                }

                else if (flavor == PlatformFlavor.SLES)
                {
                    if (System.IO.File.Exists("/etc/issue"))
                    {
                        string issueText     = System.IO.File.ReadAllText("/etc/issue");
                        var    versionString = Regex.Match(issueText, "1[0-3]");

                        if (versionString.Success)
                        {
                            return(new System.Version(Int32.Parse(versionString.ToString()), 0));
                        }
                        else
                        {
                            return(new System.Version(0, 0));
                        }
                    }
                    else
                    {
                        throw new Exception("No /etc/issue file for Flavor SLES");
                    }
                }
                else if (flavor == PlatformFlavor.OpenSUSE)
                {
                    if (System.IO.File.Exists("/etc/issue"))
                    {
                        string issueText     = System.IO.File.ReadAllText("/etc/issue");
                        var    versionString = Regex.Match(issueText, "[0-9][0-9]{2}.[0-9]{1}");

                        if (versionString.Success)
                        {
                            return(new System.Version(Int32.Parse(versionString.ToString()), 0));
                        }
                        else
                        {
                            return(new System.Version(0, 0));
                        }
                    }
                    else
                    {
                        throw new Exception("No /etc/issue file for Flavor SLES");
                    }
                }
                else if (flavor == PlatformFlavor.Ubuntu)
                {
                    if (System.IO.File.Exists("/etc/issue"))
                    {
                        string issueText     = System.IO.File.ReadAllText("/etc/issue");
                        var    versionString = Regex.Match(issueText, "[0-9]{2}.[0-9]{2}");

                        if (versionString.Success)
                        {
                            return(new System.Version(versionString.Value));
                        }
                        else
                        {
                            return(new System.Version(0, 0));
                        }
                    }
                    else
                    {
                        throw new Exception("No /etc/issue file for Flavor Ubuntu");
                    }
                }
                else
                {
                    throw new Exception("Linux flavor not implemented yet");
                }
            }
            else if (platform == PlatformID.MacOSX)
            {
                throw new NotImplementedException();
            }
            else
            {
                throw new NotImplementedException();
            }
        }
Exemple #22
0
        private void 测试内存截图ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            /*
             * Bitmap btm1 = getScreenPic();
             * Thread.Sleep(3000);
             * Bitmap btm2 = getScreenPic();
             * Stopwatch watch = new Stopwatch();
             *
             *
             * ImageCodecInfo myImageCodecInfo;
             * System.Drawing.Imaging.Encoder myEncoder;
             * EncoderParameter myEncoderParameter;
             * EncoderParameters myEncoderParameters;
             * myImageCodecInfo = GetEncoderInfo("image/tiff");
             * myEncoder = System.Drawing.Imaging.Encoder.ColorDepth;
             * myEncoderParameters = new EncoderParameters(1);
             * myEncoderParameter = new EncoderParameter(myEncoder, 16L);
             * myEncoderParameters.Param[0] = myEncoderParameter;
             *
             * watch.Start();
             * List<Rectangle> difpoints= Core.ImageComparer.Compare(btm1, btm2);
             *
             * Bitmap getDifBitmap=Core.ImageComparer.getBlocksIn1Bitmap(difpoints, btm2, new Size(10, 10));
             *
             *
             * getDifBitmap.Save("D:\\testdif.tiff", myImageCodecInfo, myEncoderParameters);
             *
             */

            /*
             * // btm1.Save(ms, ImageFormat.Jpeg);
             * //this.BackgroundImage = btm1;
             * MemoryStream ms2 = new MemoryStream();
             * Stopwatch watch = new Stopwatch();
             */
            /** Bitmap btm2 = new Bitmap(btm1.Size.Width, btm1.Size.Height);
             * 耗时严重,3秒左右
             * for (int i = 0; i < btm1.Size.Width; i++)
             * {
             *   for (int j = 0; j < btm1.Size.Height; j++)
             *   {
             *       btm2.SetPixel(i, j, btm1.GetPixel(i, j));
             *   }
             * }*/


            /*
             * //不带参数的clone效率最高,100次不到1ms
             * for (int i = 0; i < 1000; i++)
             *  btm2 = (Bitmap)btm1.Clone();//new RectangleF(0,0,600,600),System.Drawing.Imaging.PixelFormat.Format24bppRgb);
             */
            /*
             * Stopwatch watch = new Stopwatch();
             * btm1.Save(ms, ImageFormat.Jpeg);
             * ms.Close();
             * MemoryStream msIzip = new MemoryStream();
             * ZipOutputStream outZip = new ZipOutputStream(msIzip);
             * outZip.SetLevel(9);
             * outZip.PutNextEntry(new ZipEntry("KS"));
             * outZip.Write(ms.ToArray(), 0, (int)ms.ToArray().Length);
             * outZip.Close();
             * msIzip.Close();
             * watch.Start();
             * byte[] zipbytes = msIzip.ToArray();
             * MemoryStream msUnzip = new MemoryStream();
             * ZipInputStream inZip = new ZipInputStream(new MemoryStream(zipbytes));
             * inZip.GetNextEntry();
             * byte[] buf=new byte[8192];
             * int size=0;
             * while (true)
             * {
             *  size = inZip.Read(buf, 0, buf.Length);
             *  if (size == 0) break;
             *  msUnzip.Write(buf, 0, size);
             * }
             * msUnzip.Close();
             * inZip.Close();
             *
             * watch.Stop();*/
            //DeflateStream
            //GZipStream zip = new GZipStream(ms2, CompressionMode.Compress);

            // zip.Write(ms.ToArray(), 0, (int)ms.Length);
            // zip.Close();

            // MessageBox.Show("耗时:" + watch.ElapsedMilliseconds);
            //MessageBox.Show("耗时:" + watch.ElapsedMilliseconds + "压缩前大小:" + ms.ToArray().Length + "Izip:" + msIzip.ToArray().Length+"Iunzip:"+msUnzip.ToArray().Length);
            //  MessageBox.Show(Encoding.ASCII.GetBytes("KS").Length+"");

            /*
             * Bitmap btm1 = getScreenPic();
             * Thread.Sleep(3000);
             * Bitmap btm2 = getScreenPic();
             * List<Rectangle> difpoints = Core.ImageComparer.Compare(btm1, btm2);
             * Bitmap getDifBitmap = Core.ImageComparer.getBlocksIn1Bitmap(difpoints,btm2, new Size(10, 10));
             * getDifBitmap.Save("D:\\test.jpeg", ImageFormat.Bmp);
             * MemoryStream ms = new MemoryStream();
             * getDifBitmap.Save(ms, ImageFormat.Bmp);
             * ms.Close();
             * MemoryStream msIzip = new MemoryStream();
             * ZipOutputStream outZip = new ZipOutputStream(msIzip);
             * outZip.SetLevel(9);
             * outZip.PutNextEntry(new ZipEntry("KS"));
             * outZip.Write(ms.ToArray(), 0, (int)ms.ToArray().Length);
             * outZip.Close();
             * msIzip.Close();
             * Stopwatch watch = new Stopwatch();
             * watch.Start();
             * byte[] retByte = (new LZOCompressor()).Compress(ms.ToArray());
             * watch.Stop();
             * long time1 = watch.ElapsedMilliseconds;
             * watch.Reset();
             * watch.Start();
             * byte[] reByte2 = (LZ4CompressorFactory.CreateNew()).Compress(ms.ToArray());
             * watch.Stop();
             * long time2 = watch.ElapsedMilliseconds;
             * MessageBox.Show("压缩前jpeg大小:" + ms.ToArray().Length + "zip:" + msIzip.ToArray().Length + "lzo:" + retByte.Length + "time:" + time1 + "lz4_1:" + reByte2.Length +  "time:" + time2);
             */
            //FileStream fs=File.OpenWrite("D:\\testunzip2.zip");
            // fs.Write(msIzip.ToArray(), 0, msIzip.ToArray().Length);

            /*
             * MemoryStream msUnzip = new MemoryStream();
             * ZipInputStream inZip = new ZipInputStream(File.OpenRead("D:\\testunzip.zip"));
             * inZip.GetNextEntry();
             * byte[] buf = new byte[8192];
             * int size = 0;
             * while (true)
             * {
             *  size = inZip.Read(buf, 0, buf.Length);
             *  if (size == 0) break;
             *  msUnzip.Write(buf, 0, size);
             * }
             * msUnzip.Close();
             * inZip.Close();
             * File.OpenWrite("D:\\testunzip.jpeg").Write(msUnzip.ToArray(),0,msUnzip.ToArray().Length);
             * */
            /*
             * Bitmap btm1 = getScreenPic();
             * Thread.Sleep(3000);
             * Bitmap btm2 = getScreenPic();
             *
             * Stopwatch watch = new Stopwatch();
             * watch.Start();
             * List<Rectangle> difpoints = Core.ImageComparer.Compare(btm1, btm2);
             * Bitmap getDifBitmap = Core.ImageComparer.getBlocksIn1Bitmap(difpoints, btm2,btm1, new Size(10, 10));
             * watch.Stop();
             *
             * getDifBitmap.Save("D:\\testdif.png",ImageFormat.Png);
             * MessageBox.Show("耗时:" + watch.ElapsedMilliseconds + "ms");
             * */

            /*
             * Thread test = new Thread(new ThreadStart(testFun));
             * test.IsBackground = true;
             * test.Start();*/
            /*  Bitmap btm1 = getScreenPic();
             * btm1.Save("D:\\test.bmp", ImageFormat.Bmp);
             * Stopwatch watch = new Stopwatch();
             * watch.Start();
             * for (int i = 100; i > 0; i--)
             * {
             * // BitmapData bd= btm1.LockBits(new Rectangle(0, 0, btm1.Width, btm1.Height),ImageLockMode.ReadOnly,PixelFormat.Format24bppRgb);
             *    //btm2 = (Bitmap)btm3.Clone(new Rectangle(0, 0, btm1.Width, btm1.Height), PixelFormat.Format24bppRgb);
             *   // btm2 = new Bitmap(btm1.Width, btm1.Height);
             *   //btm2= Core.ImageComparer.getBlockBitmap(new Rectangle(0, 0, 800, 800), btm1);
             *   //btm2.Save("D:\\test" +i+ ".jpg", ImageFormat.Jpeg);
             *    //btm2.Dispose();
             *   //btm1.UnlockBits(bd);
             *    //new Rectangle(0, 0, 3000, 3000);
             *    getScreenPic();
             * }
             * //btm2 = Core.ImageComparer.getBlockBitmap(new Rectangle(0, 0, 800, 800), btm1);
             * watch.Stop();
             * MessageBox.Show(watch.ElapsedMilliseconds+"ms");
             */
            /*
             * Stopwatch watch = new Stopwatch();
             * watch.Start();
             * byte[] testByte1 = new byte[1920 * 1080 * 3];
             * byte[] testByte2 = new byte[1920 * 1080 * 3];
             * for (int i = 0; i < 1920 * 1080 * 3; i++)
             * {
             *  testByte1[i] =testByte2[i]= (byte)i;
             * }
             * watch.Stop();
             * MessageBox.Show(watch.ElapsedMilliseconds + "ms");*/
            /*
             * Bitmap btm1 = getScreenPic();
             * Thread.Sleep(3000);
             * Bitmap btm2 = getScreenPic();
             * Stopwatch watch = new Stopwatch();
             * watch.Start();
             * MemoryStream m1 = new MemoryStream();
             * MemoryStream m2 = new MemoryStream();
             * btm1.Save(m1, ImageFormat.Bmp);
             * btm2.Save(m2, ImageFormat.Bmp);
             * m1.Close();
             * m2.Close();
             * byte[] btmBytes1 = m1.ToArray();
             * byte[] btmBytes2 = m2.ToArray();
             * MemoryStream mo = new MemoryStream();
             * int len1=btmBytes1.Length;
             * int len2=btmBytes2.Length;
             * int forValue=Math.Min(len1,len2);
             * int ret=0;
             * for (int i = 0; i < forValue; i++)
             * {
             *  if (btmBytes1[i] != btmBytes2[i])
             *  {
             *      mo.WriteByte(btmBytes2[i]);
             *      ret++;
             *      //Console.WriteLine("index:" + i);
             *  }
             * }
             * byte[] retByte = (new LZOCompressor()).Compress(mo.ToArray());
             * watch.Stop();
             * mo.Close();
             *
             * MessageBox.Show("times:" + watch.ElapsedMilliseconds + "ms " + "dif:" + ret + " lzo:" + retByte.Length);
             * */

            //获取系统信息
            System.OperatingSystem osInfo = System.Environment.OSVersion;

            //获取操作系统ID
            System.PlatformID platformID = osInfo.Platform;
            //获取主版本号
            int versionMajor = osInfo.Version.Major;
            //获取副版本号
            int versionMinor = osInfo.Version.Minor;

            MessageBox.Show("platformID:" + platformID.ToString() + " Major:" + versionMajor + " minor:" + versionMinor);
        }
 public WindowsVersion(System.PlatformID plID, Version version)
 {
     PlatformID = plID;
     Version    = version;
 }
Exemple #24
0
 public FileSystemLog(HashSet <string> verbosity) : base(verbosity)
 {
     this._platform = Environment.OSVersion.Platform;
     this._logPath  = System.Reflection.Assembly.GetExecutingAssembly().Location + ".log";
 }
 private OperatingSystem(SerializationInfo information, StreamingContext context)
 {
     _platform    = (System.PlatformID)information.GetValue("_platform", typeof(System.PlatformID));
     _version     = (Version)information.GetValue("_version", typeof(Version));
     _servicePack = information.GetString("_servicePack");
 }