c# - 如何在 VS 2010 安装项目之前进行目标系统要求测试 c#

标签 c# installation setup-deployment performance-testing

我有一个应用程序需要使用 Oracle 32 位版本。我知道,我可以将其添加为先决条件,如果它尚未安装在目标机器上,它将被下载并安装完成。

实际上我的要求是“我需要进行系统性能测试,例如内存大小、处理器速度、鼠标可用性、键盘可用性、打印机可用性、系统最大屏幕分辨率支持等。

我是否有可能在设置前测试所有信息?

我是部署项目的新手,您能告诉我从哪里开始吗?

最佳答案

我不确定如何使用这些单独的函数,但这里有一些函数可以检查不同的东西:

        //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;
        }

注意:我只是使用 Console.WriteLine 以便您可以看到值,并且还使用 LIST,因此如果您愿意,可以进一步使用这些项目。

还可以阅读一些文章,例如 How To Get Hardware Information (CPU ID, MainBoard Info, Hard Disk Serial, System Information , ...)

关于c# - 如何在 VS 2010 安装项目之前进行目标系统要求测试 c#,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15378098/

相关文章:

c# - 在 xamarin 表单上动态绑定(bind)图像源

hadoop - 使用 start-dfs.sh 的问题

c++ - 使用单独的 Boost 库编译,无需安装 Boost

c# - 使用 sql 数据库部署 wpf 应用程序

c# - 有没有办法让 Newtonsoft.Create 在界面上调用您的自定义创建方法?

c# - 用于数组传递和返回的 Microsoft 中间语言代码 [MSIL]

ubuntu - 无法在 ubuntu 20.04 中安装 g++ 和 build-essentials

web-applications - Web 应用程序的设置和部署

c# - 传递 .msi 参数以安装自定义操作

c# - 为什么派生类的泛型会产生非派生类?