如何在vs2010安装项目c#之前进行目标系统需求测试

本文关键字:目标 测试 系统需求 vs2010 安装 项目 | 更新日期: 2023-09-27 18:03:50

我有一个需要使用Oracle 32位版本的应用程序。我明白了,我可以添加这个作为先决条件,如果它还没有安装在目标机器上,它将被下载并安装完成。

实际上我的要求是"我需要做系统性能测试,如ram大小,处理器速度,鼠标可用性,键盘可用性,打印机可用性,系统最大屏幕分辨率支持等"

是否有可能在安装前测试所有信息?

我是新来的部署一个项目,你能告诉我从哪里开始吗?

如何在vs2010安装项目c#之前进行目标系统需求测试

我不确定如何使用这些单独的函数,但这里是检查不同事情的函数:

        //Get system RAM
        private double GetSystemRam()
        {
            var searcher = new ManagementObjectSearcher("Select * From Win32_ComputerSystem");
            double total_Ram_Bytes = 0;
            foreach (ManagementObject Mobject in searcher.Get())
            {
                total_Ram_Bytes = (Convert.ToDouble(Mobject["TotalPhysicalMemory"]));
                Console.WriteLine("RAM Size in Giga Bytes: {0}", total_Ram_Bytes / 1073741824);
            }
            return total_Ram_Bytes;
        }

        //Get system processor speed
        private int GetprocessorSpeed()
        {
            var searcher = new ManagementObjectSearcher("select MaxClockSpeed from Win32_Processor");
            int processorSpeed = 0;
            foreach (var item in searcher.Get())
            {
                processorSpeed = Convert.ToInt32(item["MaxClockSpeed"]);
                Console.WriteLine("Processor Speed is(GHz):" + processorSpeed);
            }
            return processorSpeed;
        }

        //Get system maximum resolution
        private void GetMaxResolution()
        {
            using (var searcher = new System.Management.ManagementObjectSearcher("SELECT * FROM CIM_VideoControllerResolution"))
            {
                var results = searcher.Get();
                UInt32 maxHResolution = 0;
                UInt32 maxVResolution = 0;
                foreach (var item in results)
                {
                    if ((UInt32)item["HorizontalResolution"] > maxHResolution)
                        maxHResolution = (UInt32)item["HorizontalResolution"];
                    if ((UInt32)item["VerticalResolution"] > maxVResolution)
                        maxVResolution = (UInt32)item["VerticalResolution"];
                }
                Console.WriteLine("Max Supported Resolution " + maxHResolution + "x" + maxVResolution);
            }
        }

        //Check for availability of keyboard 
        private bool IsKeyboardAvailable()
        {
            bool isKeyboardAvailable = false;
            var searcher = new ManagementObjectSearcher("select * from Win32_Keyboard");
            List<string> keyBoardName = new List<string>();
            foreach (var item in searcher.Get())
            {
                keyBoardName.Add(Convert.ToString(item["Name"]));
                Console.WriteLine("KeyBoard name is :" + item["Name"]);
                isKeyboardAvailable = true;
            }
            return isKeyboardAvailable;
        }

        //Check for availability of printer
        private bool IsPrinterAvailable()
        {
            bool isPrinterAvailable = false;
            var searcher = new ManagementObjectSearcher("Select * from Win32_Printer");
            List<string> printerName = new List<string>();
            foreach (var item in searcher.Get())
            {
                printerName.Add(item["Name"].ToString().ToLower());
                Console.WriteLine("Printer name is :" + item["Name"]);
                isPrinterAvailable = true;
            }
            return isPrinterAvailable;
        }

        //Check for availability of mouse
        private bool IsMouseAvailable()
        {
            bool isMouseAvailable = false;
            var searcher = new ManagementObjectSearcher("Select * from Win32_PointingDevice");
            List<string> mouseType = new List<string>();
            foreach (var item in searcher.Get())
            {
                mouseType.Add(item["Name"].ToString().ToLower());
                Console.WriteLine("Mouse type is :" + item["Name"]);
                isMouseAvailable = true;
            }
            return isMouseAvailable;
        }

注意:我只是使用控制台。WriteLine,这样你就可以看到值,也可以使用LIST,所以如果你想,你可以进一步使用这些项。

也可以阅读一些文章,如如何获取硬件信息(CPU ID,主板信息,硬盘串口,系统信息,…)