Unity中根據裝置名稱獲取串口號

2021-09-22 21:25:19 字數 999 閱讀 9386

首先說一下在unity中對串列埠的支援並不是很好,要實現的是根據裝置名稱獲取串口號。經過很多嘗試,借鑑了下面的兩篇文章最後決定在net環境中單獨製作乙個exe用來獲取裝置名稱對應的串口號,然後在unity環境中進行呼叫。

一、net環境中根據裝置名稱獲取串口號的**

using system.management;

using system;

using system.collections.generic;

class program

/// /// get the target com num.

///

///

public static int getcomnum()

}return comnum;

}/// /// get the system devices information with windows api.

///

/// device type.

/// the property of the device.

///

private static string getharewareinfo(hardwareenum hardtype, string propkey)}}

return strs.toarray();

}catch

finally

}//end of func getharewareinfo().

/// /// 列舉win32 api

///

public enum hardwareenum

}

private string getportname()

catch (exception ex)

}

4 iOS獲取裝置名稱

適配一直是移動開發人員的痛苦之處。那麼今天在這裡把關於適配中獲取裝置名稱的方法匯合一下。這是乙個類方法,需要匯入系統的標頭檔案 import 裝置名稱 nsstring getddevicename else if strmodel isequaltostring ipad2,1 strmodel ...

根據程序名稱或者服務名稱用WMI獲取執行路徑和引數

自己動手,起碼可以用程序獲取路徑吧,看到博問上 winform 獲得已啟動服務的啟動引數 呵呵,這兩個貌似一種方法可以解決啊 wmi,還記得嗎?1 private static string getresultbywql string wql 212 13return null 14 呵呵,wmi功...

C 根據程序名稱獲取程序的控制代碼?

c 根據程序名稱獲取程序的控制代碼或c 如何獲取其他程序的控制代碼?有時候標題名是動態變化的,所以不使用findwindow方法!structlayout layoutkind.sequential public struct processentry32 dllimport kernel32.dl...