由于需要获取显卡信息,但是unity的自带函数,只能输出1个显卡

c#倒是可以但是引用了一个下载的dll   System.Management.dll

这个dll放到unity用不了,因为mono不支持

所以先用vs写个外部exe程序

using System;
using System.Management; public class Sample
{
public static void Main(string[] args)
{
string Gname = ""; ManagementObjectSearcher objvide = new ManagementObjectSearcher("select * from Win32_VideoController"); foreach (ManagementObject obj in objvide.Get())
{
Gname += ("Name - " + obj["Name"] + "</br>");
//System.Console.WriteLine("Name - " + obj["Name"] + "</br>");
//System.Console.WriteLine("DeviceID - " + obj["DeviceID"] + "</br>");
//System.Console.WriteLine("AdapterRAM - " + obj["AdapterRAM"] + "</br>");
//System.Console.WriteLine("AdapterDACType - " + obj["AdapterDACType"] + "</br>");
//System.Console.WriteLine("Monochrome - " + obj["Monochrome"] + "</br>");
//System.Console.WriteLine("InstalledDisplayDrivers - " + obj["InstalledDisplayDrivers"] + "</br>");
//System.Console.WriteLine("DriverVersion - " + obj["DriverVersion"] + "</br>");
//System.Console.WriteLine("VideoProcessor - " + obj["VideoProcessor"] + "</br>");
//System.Console.WriteLine("VideoArchitecture - " + obj["VideoArchitecture"] + "</br>");
//System.Console.WriteLine("VideoMemoryType - " + obj["VideoMemoryType"] + "</br>"); //Console.WriteLine("=====================================================");
} Console.WriteLine(Gname);
Console.WriteLine("=====================================================");
//Console.ReadKey();
}
}

然后生成运行下

Unity代码

using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using UnityEngine; public class GetSystemInfo : MonoBehaviour { string a = ""; // Use this for initialization
void Start () { //这种方法可以
GetStr(); //这种方法也可以
//OpenEXE("C://Users/zts/source/repos/ConsoleApp9/ConsoleApp9/bin/Debug/ConsoleApp9.exe", "");
} /// <summary>
///
/// </summary>
/// <param name="_exePathName">路径</param>
/// <param name="_exeArgus">启动参数</param>
public void OpenEXE(string _exePathName, string _exeArgus)
{
try
{
Process myprocess = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo(_exePathName, _exeArgus);
myprocess.StartInfo = startInfo;
myprocess.StartInfo.CreateNoWindow = true;
myprocess.StartInfo.UseShellExecute = false;
myprocess.StartInfo.RedirectStandardOutput = true;
//myprocess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
myprocess.Start();
a += myprocess.StandardOutput.ReadLine();//只能读取1行
UnityEngine.Debug.Log(a);
myprocess.WaitForExit();
}
catch (Exception ex)
{
UnityEngine.Debug.Log("出错原因:" + ex.Message);
}
} public void GetStr()
{
try
{
Process proc = new Process();
proc.EnableRaisingEvents = false;
proc.StartInfo.FileName = "C://Users/zts/source/repos/ConsoleApp9/ConsoleApp9/bin/Debug/ConsoleApp9.exe";
proc.StartInfo.CreateNoWindow = true;
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.RedirectStandardOutput = true;
//proc.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;//这句会让unity卡死
proc.Start();
string fingerprint = proc.StandardOutput.ReadLine();
UnityEngine.Debug.Log(fingerprint);
proc.WaitForExit();
}
catch (Exception)
{ throw;
} } /********************************unity获取设备信息*******************************/
string systemInfo;
public void GetUnityInfo()
{
systemInfo = "\tTitle:当前系统基础信息:\n设备模型:" + SystemInfo.deviceModel + "\n设备名称:" + SystemInfo.deviceName + "\n设备类型:" + SystemInfo.deviceType +
"\n设备唯一标识符:" + SystemInfo.deviceUniqueIdentifier + "\n显卡标识符:" + SystemInfo.graphicsDeviceID +
"\n显卡设备名称:" + SystemInfo.graphicsDeviceName + "\n显卡厂商:" + SystemInfo.graphicsDeviceVendor +
"\n显卡厂商ID:" + SystemInfo.graphicsDeviceVendorID + "\n显卡支持版本:" + SystemInfo.graphicsDeviceVersion +
"\n显存(M):" + SystemInfo.graphicsMemorySize + "\n显卡像素填充率(百万像素/秒),-1未知填充率:" + SystemInfo.graphicsPixelFillrate +
"\n显卡支持Shader层级:" + SystemInfo.graphicsShaderLevel + "\n支持最大图片尺寸:" + SystemInfo.maxTextureSize +
"\nnpotSupport:" + SystemInfo.npotSupport + "\n操作系统:" + SystemInfo.operatingSystem +
"\nCPU处理核数:" + SystemInfo.processorCount + "\nCPU类型:" + SystemInfo.processorType +
"\nsupportedRenderTargetCount:" + SystemInfo.supportedRenderTargetCount + "\nsupports3DTextures:" + SystemInfo.supports3DTextures +
"\nsupportsAccelerometer:" + SystemInfo.supportsAccelerometer + "\nsupportsComputeShaders:" + SystemInfo.supportsComputeShaders +
"\nsupportsGyroscope:" + SystemInfo.supportsGyroscope + "\nsupportsImageEffects:" + SystemInfo.supportsImageEffects +
"\nsupportsInstancing:" + SystemInfo.supportsInstancing + "\nsupportsLocationService:" + SystemInfo.supportsLocationService +
"\nsupportsRenderTextures:" + SystemInfo.supportsRenderTextures + "\nsupportsRenderToCubemap:" + SystemInfo.supportsRenderToCubemap +
"\nsupportsShadows:" + SystemInfo.supportsShadows + "\nsupportsSparseTextures:" + SystemInfo.supportsSparseTextures +
"\nsupportsStencil:" + SystemInfo.supportsStencil + "\nsupportsVertexPrograms:" + SystemInfo.supportsVertexPrograms +
"\nsupportsVibration:" + SystemInfo.supportsVibration + "\n内存大小:" + SystemInfo.systemMemorySize;
}
void OnGUI()
{
GUILayout.Label(systemInfo);
}
/************************************************************************/ // Update is called once per frame
void Update () { }
}

===========

改良下

    public void GetStr()
{
try
{
Process proc = new Process();
proc.EnableRaisingEvents = false;
proc.StartInfo.FileName = "C://Users/zts/source/repos/ConsoleApp9/ConsoleApp9/bin/Debug/ConsoleApp9.exe";
proc.StartInfo.CreateNoWindow = true;
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.RedirectStandardOutput = true;
//proc.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;//这句会让unity卡死
proc.Start();
a += proc.StandardOutput.ReadToEnd();
proc.WaitForExit();
proc.Close();
UnityEngine.Debug.Log(a);
}
catch (Exception)
{ throw;
} }

unity 读取外部exe程序控制台信息的更多相关文章

  1. spring(读取外部数据库配置信息、基于注解管理bean、DI)

    ###解析外部配置文件在resources文件夹下,新建db.properties(和数据库连接相关的信息) driverClassName=com.mysql.jdbc.Driverurl=jdbc ...

  2. 如何用DELPHI编程修改外部EXE文件的版本信

    右击里面有修改 点开直接修改就可以了吧. DELPHI 里程序的版本信息怎么是灰色的,无法更改 耐心读以下说明,应该能解决你的问题,如果不能解决,请Hi我~ 如何给自己的dll文件添加版本信息呢? 首 ...

  3. 直接读取修改exe文件

    1. 前言 配置器的编写有很多的方式,主要是直接修改原始的受控端的程序,有的方式是把受控端和配置信息都放到控制端程序的内部,在需要配置受控端的时候直接输入配置信息,生成受控端:也有的方式是在外部直接修 ...

  4. Unity3D移动平台动态读取外部文件全解析

    前言: 一直有个想法,就是把工作中遇到的坑通过自己的深挖,总结成一套相同问题的解决方案供各位同行拍砖探讨.眼瞅着2015年第一个工作日就要来到了,小匹夫也休息的差不多了,寻思着也该写点东西活动活动大脑 ...

  5. windows下调用外部exe程序 SHELLEXECUTEINFO

    本文主要介绍两种在windows下调用外部exe程序的方法: 1.使用SHELLEXECUTEINFO 和 ShellExecuteEx SHELLEXECUTEINFO 结构体的定义如下: type ...

  6. C#和asp.net执行外部EXE程序

    这两天研究下.Net的执行外部EXE程序问题,就是在一个程序里通过按钮或其他操作运行起来另外一个程序,需要传入参数,如用户名.密码之类(实际上很类似单点登录,不过要简单的多的多):总结如下: 1.CS ...

  7. (转)Unity3D移动平台动态读取外部文件全解析

    Unity3D移动平台动态读取外部文件全解析 c#语言规范 阅读目录 前言: 假如我想在editor里动态读取文件 移动平台的资源路径问题 移动平台读取外部文件的方法 补充: 回到目录 前言: 一直有 ...

  8. Spring读取外部属性-properties

    概述 在Spring中处理外部值最简常用的方法就是外部创建name.properties文件,并在其中声明变量值,供Java进行读取.比如数据源信息配置,Java固定属性位置等.读取的方式一般由三种: ...

  9. sas通过IMPORT过程读取外部文件数据

    SAS通过IMPORT过程读取外部文件数据 使用IMPORT过程导入带分隔符的文件外,Microsoft Access数据库文件.Miscrosft Excel工作簿. dBase文件.JMP文件.S ...

随机推荐

  1. COLLATE 函数

    指定SQL server的排序规则Chinese_PRC指的是中国大陆地区,如果是台湾地区则为Chinese_TaiwanCI指定不区分大小写,如果要在查询时区分输入的大小写则改为CSAS指定区分重音 ...

  2. Linq善解人意之通过MSDN对14个“查询关键字“逐个解剖

    linq中存在的 14个关键字 网址: https://msdn.microsoft.com/zh-cn/library/bb310804.aspx from: 迭代变量 where:对数据源进行逻辑 ...

  3. redis----内部数据结构学习

    整数集合 1.应用 用于有序.无重复的保存多个整数值 自动选择该用什么长度的整数类型保存数据

  4. elasticsearch(0.90.10)安装配置+超多插件!!

    一)安装elasticsearch 1)下载elasticsearch-0.90.10,解压,运行\bin\elasticsearch.bat (windwos) 2)进入http://localho ...

  5. Nutch2.2.1,window,eclipse,安装

    教程:https://app.yinxiang.com/shard/s12/sh/36b8e911-2d0e-4ee4-b34f-a426c6dc99c2/9543f94cd8abf12b4b9857 ...

  6. Django Query

    Making Qeries 一旦创建了数据模型,Django就会自动为您提供一个数据库抽象API,允许您创建.检索.更新和删除对象.本文档解释了如何使用这个API. The models 一个clas ...

  7. 《Beginning Java 7》 - 8 - Collecting Garbage 垃圾回收

    Java 垃圾回收机制原理: Java 语言使用 garbage collector 来进行垃圾回收.它是允许在后台的代码,间或地检查没有引用的对象(unreferenced object).发现后, ...

  8. ubuntu里面如何以root身份使用图形界面管理文件?

    nautilus 是gnome的文件管理器,但是如果不是root账号下,权限受限,我们可以通过以下方式以root权限使用! 一,快捷键“Ctrl+Alt+t”,调出shell. 二,在shell中输入 ...

  9. 实验1 C语言运行环境的使用和数据类型、运算符和表达式

    Part1 这一部分的内容虽然简单,但是对于初学的我来说,独自完成且没有错误还是不容易的,像老师说的一样,只有自己亲手编写以后才可以发现问题并且逐步改正.从这次实践我对与C语言程序的结构更加熟悉.   ...

  10. java String拼接的方法选择及性能分析

    String 拼接的方法选择 在拼接静态字符串时,尽量用 +,因为通常编译器会对此做优化,如: String test = "this " + "is " + ...