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 ...
随机推荐
- Integer.MIN_VALUE
static int MAX_VALUE 值为 2^31-1 的常量,它表示 int 类型能够表示的最大值. static int MIN_VALUE 值为 - ...
- IO--RAID
RAID IO计算 Raid 0 –每个磁盘的I/O计算= (读+写) /磁盘个数 Raid 1 --每个磁盘的I/O计算= [读+(2*写)]/2 Raid 5 --每个磁盘的I/O计算= [读+( ...
- 使用pycharm专业版创建虚拟环境
Location为工程地址 D:\My_python 第二个Location为 虚拟环境放在这个工程下 Base interpreter:基于那个解释器来创建虚拟环境 Create后进入到目录查看下
- 高性能无锁队列 Disruptor 初体验
原文地址: haifeiWu和他朋友们的博客 博客地址:www.hchstudio.cn 欢迎转载,转载请注明作者及出处,谢谢! 最近一直在研究队列的一些问题,今天楼主要分享一个高性能的队列 Disr ...
- nowcoder(牛客网)提高组模拟赛第四场 解题报告
T1 动态点分治 就是模拟..... 但是没有过!! 看了题解之后发现.... 坑点:有可能 \(x<=r\),但是
- kvm虚拟机动态迁移
相比KVM虚拟机静态迁移中需要拷贝虚拟机虚拟磁盘文件,kvm虚拟机动态迁移无需拷贝虚拟磁盘文件,但是需要迁移到的虚拟主机之间需要有相同的目录结构虚拟机磁盘文件,本文这部分内容通过nfs来实现,当然也可 ...
- Redis数据持久化,安全
一.redis数据持久化 由于redis是一个内存数据库,如果系统遇到致命问题需要关机或重启,内存中的数据就会丢失,这是生产环境所不能允许的.所以redis提供了数据持久化的能力. redis提供了两 ...
- 【spring】SpringBoot之Servlet、Filter、Listener配置
转载自 http://blog.csdn.net/king_is_everyone/article/details/53116744 1.介绍 通过之前的文章来看,SpringBoot涵盖了很多配置, ...
- P1117 [NOI2016]优秀的拆分
$ \color{#0066ff}{ 题目描述 }$ 如果一个字符串可以被拆分为\(AABB\)的形式,其中 A和 B是任意非空字符串,则我们称该字符串的这种拆分是优秀的. 例如,对于字符串\(aab ...
- Oracle PL/SQL学习之你需要知道的快捷键
1.格式化sql语句 Ctrl+A 然后 Ctrl+F7 2.窗口最大化最小化 首选项-->快捷键-->Maximize Toggle,然后修改成自己熟悉的快捷键设置.