由于需要获取显卡信息,但是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. thinkjs 框架图

  2. 通过python实现wc基本功能

    ---恢复内容开始--- 1.Github项目地址: https://github.com/zhg1998/ww/blob/master/wc.py 2.项目相关要求: 写一个命令行程序,模仿已有wc ...

  3. Panda3d code in github

    https://github.com/panda3d/panda3d [ref files] http://www.panda3d.noie.name/ https://www.panda3d.org ...

  4. copymemory()数组赋值

    在各网站的文章里面,见复制数据的方法中,有move的,有system.copy的,而要实际应用中,这两种方法,并不是很完美,会遇到一些问题,比如copy在记录里面的复制时,编译都过不去,而CopyMe ...

  5. scvmm2008 错误 2941 0x80072efe

    该错误是由于vmm和主机之间的证书不匹配所导致的. 1. 运行mmc,文件=>添加管理单元=>添加证书=>计算机账户=>本地计算机. 2. 在下图各个目录证书下删除和vmm关联 ...

  6. [CSS]利用伪元素实现一些特殊图形 from baidu校招

    最近在博客园看到某人发的baidu校招题目,说是要用一行html代码实现下面的这个图形: 给定的html代码是: <div class='square'></div> ---- ...

  7. C#里面获得应用程序的当前路径

    在C#里面获得应用程序的当前路径 Environment.CurrentDirectorySystem.IO.Directory.GetCurrentDirectory() ——上面两种获得的是当前路 ...

  8. Javascript中的闭包(转载)

    前面的话: 闭包,是 javascript 中重要的一个概念,对于初学者来讲,闭包是一个特别抽象的概念,特别是ECMA规范给的定义,如果没有实战经验,你很难从定义去理解它.下面是作者从作用域链慢慢讲到 ...

  9. Linux centos 6.4安装

    Linux系统安装: 开启虚拟机: 界面说明:Install or upgrade an existing system 安装或升级现有的系统install system with basic vid ...

  10. win10打开移动热点让手机连接上网教程

    概述: 为什么要这么做呢? 我笔记本插网线可以上网,但是没有买猫盒,所以只能pc开热点,让手机上网. 过程如下: 1开启移动热点,设置密码 1.1开启移动热点,截图如下: 1.2设置热点名称,密码 2 ...