【问题标题】:How to do Target System Requirements test before VS 2010 Setup projects c#如何在 VS 2010 安装项目 c# 之前进行目标系统要求测试
【发布时间】:2013-02-28 23:05:08
【问题描述】:

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

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

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

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

【问题讨论】:

    标签: c# installation setup-deployment performance-testing


    【解决方案1】:

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

            //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 , ...)

    【讨论】:

    • 感谢您的回复。我需要的主要是如何在设置之前对其进行验证。
    • 是的,因为我不知道你在项目中做了什么,所以我只是创建了单独的函数,希望它对你有所帮助。
    • 或许您可以将custom prerequisite package 添加到您的安装程序中,然后在 元素中使用 运行自定义程序进行性能测试(请参阅ClickOnce Bootstrapper reference
    • 感谢@Alexander,这是我正在寻找的内容。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-18
    • 1970-01-01
    相关资源
    最近更新 更多