unity 读取外部exe程序控制台信息
由于需要获取显卡信息,但是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程序控制台信息的更多相关文章
- spring(读取外部数据库配置信息、基于注解管理bean、DI)
###解析外部配置文件在resources文件夹下,新建db.properties(和数据库连接相关的信息) driverClassName=com.mysql.jdbc.Driverurl=jdbc ...
- 如何用DELPHI编程修改外部EXE文件的版本信
右击里面有修改 点开直接修改就可以了吧. DELPHI 里程序的版本信息怎么是灰色的,无法更改 耐心读以下说明,应该能解决你的问题,如果不能解决,请Hi我~ 如何给自己的dll文件添加版本信息呢? 首 ...
- 直接读取修改exe文件
1. 前言 配置器的编写有很多的方式,主要是直接修改原始的受控端的程序,有的方式是把受控端和配置信息都放到控制端程序的内部,在需要配置受控端的时候直接输入配置信息,生成受控端:也有的方式是在外部直接修 ...
- Unity3D移动平台动态读取外部文件全解析
前言: 一直有个想法,就是把工作中遇到的坑通过自己的深挖,总结成一套相同问题的解决方案供各位同行拍砖探讨.眼瞅着2015年第一个工作日就要来到了,小匹夫也休息的差不多了,寻思着也该写点东西活动活动大脑 ...
- windows下调用外部exe程序 SHELLEXECUTEINFO
本文主要介绍两种在windows下调用外部exe程序的方法: 1.使用SHELLEXECUTEINFO 和 ShellExecuteEx SHELLEXECUTEINFO 结构体的定义如下: type ...
- C#和asp.net执行外部EXE程序
这两天研究下.Net的执行外部EXE程序问题,就是在一个程序里通过按钮或其他操作运行起来另外一个程序,需要传入参数,如用户名.密码之类(实际上很类似单点登录,不过要简单的多的多):总结如下: 1.CS ...
- (转)Unity3D移动平台动态读取外部文件全解析
Unity3D移动平台动态读取外部文件全解析 c#语言规范 阅读目录 前言: 假如我想在editor里动态读取文件 移动平台的资源路径问题 移动平台读取外部文件的方法 补充: 回到目录 前言: 一直有 ...
- Spring读取外部属性-properties
概述 在Spring中处理外部值最简常用的方法就是外部创建name.properties文件,并在其中声明变量值,供Java进行读取.比如数据源信息配置,Java固定属性位置等.读取的方式一般由三种: ...
- sas通过IMPORT过程读取外部文件数据
SAS通过IMPORT过程读取外部文件数据 使用IMPORT过程导入带分隔符的文件外,Microsoft Access数据库文件.Miscrosft Excel工作簿. dBase文件.JMP文件.S ...
随机推荐
- 12、Semantic-UI之输入框
12.1 基础输入框 在Semantic-UI中可以定义多个样式的输入框,可以将图片与输入框结合,输入提示信息文字,设置输入框的状态. 示例:定义基础输入框 用户名: <div class= ...
- dede上传文件乱码问题解决
修改下列两个文件: /include/dialog/select_soft_post.php/include/dialog/select_soft.php 改: select_soft.php文件第1 ...
- django drf 初探serializer
1.定义Model对应的serializer from rest_framework import serializers class GoodsSerializer(serializers.Seri ...
- 【QTP-场景恢复】Post-Recovery Test Run Options Screen
Post-Recovery Test Run Options Screen When you clear the Add another recovery operation check box in ...
- 迫不得已! ! 仅仅针对IE浏览器的样式,尤其是IE8及以下
IE10不会起作用,IE9,8,7,6,5都可以 <html> <head> <title>IE打开就是蓝色背景,白色的字体</title> <! ...
- 快速启动工具Rulers 3.6
云盘下载:https://yunpan.cn/cq7mumZ5uzzgw (提取码:b16a) 能根据已经安装的所有软件的名称快速查询到并回车迅速打开1.Alt+空格无特效或者Alt键有特效控制显示和 ...
- POJ2299 Ultra-QuickSort (JAVA)
思路是分治,和归并排序一模一样,只是在归并的过程中,顺便统计后半部分序列比前半部分序列小的有多少个 但一直WA,最后是结果数量比较大,会超过int,用long就ac了..做题真坎坷 贴AC代码 imp ...
- git 常用口令
版本管理 svn git cd d 切换目录 cd www cd git git clone 一个地址 git status 获取修改的内容 git add * 上传修改的内容 git commi ...
- Saiku2.6 保存查询后,重新打开报 Error Loading Query错误。
发现Saiku2.6的查询保存后重新打开就会报如下错误,同等的Schema文件和数据库环境在3.15环境里面打开是一切正常的. 后面对比了一下2.6和3.15的启动环境,发现有些差异的地方. 2.6启 ...
- 基础篇:6.9)GD&T较线性尺寸公差的优缺点
本章目的:理解GD&T标注对比线性/传统/坐标尺寸公差的优势,但也不要忘记其使用限制. 1.线性尺寸公差 1.1 定义 线性尺寸公差=传统尺寸公差=坐标尺寸公差. 传统尺寸公差(Tradi ...