Windows 下讀取DMI資訊的方法
// wdmi.cpp : Defines the entry point for the console application. // Open source.... you can refer to below code.... #include "stdafx.h" #include #include #include typedef struct _dmi_header { BYTE type; BYTE length; WORD handle; }dmi_header; typedef struct _RawSMBIOSData { BYTE Used20CallingMethod; BYTE SMBIOSMajorVersion; BYTE SMBIOSMinorVersion; BYTE DmiRevision; DWORD Length; BYTE SMBIOSTableData[]; }RawSMBIOSData; static const char *dmi_chassis_type(BYTE code) { /* 7.4.1 */ static const char *type[] = { "Other", /* 0x01 */ "Unknown", "Desktop", "Low Profile Desktop", "Pizza Box", "Mini Tower", "Tower", "Portable", "Laptop", "Notebook", "Hand Held", "Docking Station", "All In One", "Sub Notebook", "Space-saving", "Lunch Box", "Main Server Chassis", /* CIM_Chassis.ChassisPackageType says "Main System Chassis" */ "Expansion Chassis", "Sub Chassis", "Bus Expansion Chassis", "Peripheral Chassis", "RAID Chassis", "Rack Mount Chassis", "Sealed-case PC", "Multi-system", "CompactPCI", "AdvancedTCA", "Blade", "Blade Enclosing" /* 0x1D */ }; code &= 0x7F; /* bits 6:0 are chassis type, 7th bit is the lock bit */ if (code >= 0x01 && code <= 0x1D) return type[code - 0x01]; return "unknown"; } static void dmi_system_uuid(const BYTE *p, short ver) { int only0xFF = 1, only0x00 = 1; int i; for (i = 0; i < 16 && (only0x00 || only0xFF); i++) { if (p[i] != 0x00) only0x00 = 0; if (p[i] != 0xFF) only0xFF = 0; } if (only0xFF) { printf("Not Present"); return; } if (only0x00) { printf("Not Settable"); return; } /* * As of version 2.6 of the SMBIOS specification, the first 3 * fields of the UUID are supposed to be encoded on little-endian. * The specification says that this is the defacto standard, * however I've seen systems following RFC 4122 instead and use * network byte order, so I am reluctant to apply the byte-swapping * for older versions. */ if (ver >= 0x0206) printf("%02X%02X%02X%02X-%02X%02X-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X\n", p[3], p[2], p[1], p[0], p[5], p[4], p[7], p[6], p[8], p[9], p[10], p[11], p[12], p[13], p[14], p[15]); else printf("-%02X%02X%02X%02X-%02X%02X-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X\n", p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7], p[8], p[9], p[10], p[11], p[12], p[13], p[14], p[15]); } const char *dmi_string(const dmi_header *dm, BYTE s) { char *bp = (char *)dm; size_t i, len; if (s == 0) return "Not Specified"; bp += dm->length; while (s > 1 && *bp) { bp += strlen(bp); bp++; s--; } if (!*bp) return "BAD_INDEX"; /* ASCII filtering */ len = strlen(bp); for (i = 0; i < len; i++) if (bp[i] < 32 || bp[i] == 127) bp[i] = '.'; return bp; } int _tmain(int argc, _TCHAR* argv[]) { DWORD bufsize = 0; BYTE buf[65536] = {0}; int ret = 0; RawSMBIOSData *Smbios; dmi_header *h = NULL; int flag = 1; ret = GetSystemFirmwareTable('RSMB', 0, 0, 0); if (!ret) { printf("Function failed!\n"); return 1; } printf("get buffer size is %d\n", ret); bufsize = ret; ret = GetSystemFirmwareTable('RSMB', 0, buf, bufsize); if (!ret) { printf("Function failed!\n"); return 1; } Smbios = (RawSMBIOSData *)buf; BYTE *p = Smbios->SMBIOSTableData; if (Smbios->Length != bufsize -8 ) { printf("Smbios length error\n"); return 1; } for(int i =0; iLength; i++){ h = (dmi_header *)p; if (h->type == 0 && flag) { printf("\nType %02d - [BIOS]\n", h->type); printf("\tBIOS Vendor : %s\n", dmi_string(h, p[0x4])); printf("\tBIOS Version: %s\n", dmi_string(h, p[0x5])); printf("\tRelease Date: %s\n", dmi_string(h, p[0x8])); if(p[0x16]!=0xff && p[0x17]!=0xff) printf("\tEC version: %d.%d\n", p[0x16], p[0x17]); flag = 0; } else if (h->type == 1) { printf("\nType %02d - [System Information]\n", h->type); printf("\tManufacturer: %s\n", dmi_string(h, p[0x4])); printf("\tProduct Name: %s\n", dmi_string(h, p[0x5])); printf("\tVersion: %s\n", dmi_string(h, p[0x6])); printf("\tSerial Number: %s\n", dmi_string(h, p[0x7])); printf("\tUUID: "); dmi_system_uuid(p+0x8, Smbios->SMBIOSMajorVersion*0x100+Smbios->SMBIOSMinorVersion); printf("\tSKU Number: %s\n", dmi_string(h, p[0x19])); printf("\tFamily: %s\n", dmi_string(h, p[0x1a])); } else if (h->type == 2) { printf("\nType %02d - [System Information]\n", h->type); printf("\tManufacturer: %s\n", dmi_string(h, p[0x4])); printf("\tProduct: %s\n", dmi_string(h, p[0x5])); printf("\tVersion: %s\n", dmi_string(h, p[0x6])); printf("\tSerial Number: %s\n", dmi_string(h, p[0x7])); printf("\tAsset Tag: %s\n", dmi_string(h, p[0x8])); printf("\tLocation in Chassis: %s\n", dmi_string(h, p[0x0a])); } else if (h->type == 3) { printf("\nType %02d - [System Enclosure or Chassis]\n", h->type); printf("\tManufacturer: %s\n", dmi_string(h, p[0x04])); printf("\tType: %s\n", dmi_chassis_type(p[0x05])); printf("\tVersion: %s\n", dmi_string(h, p[0x06])); printf("\tSerial Number: %s\n", dmi_string(h, p[0x07])); printf("\tAsset Tag Number: %s\n", dmi_string(h, p[0x08])); printf("\tVersion: %s\n", dmi_string(h, p[0x10])); } else if(h->type == 4){ printf("\nType %02d - [Processor Information]\n", h->type); printf("\tSocket Designation: %s\n", dmi_string(h, p[0x04])); printf("\tProcessor Manufacturer: %s\n", dmi_string(h, p[0x07])); printf("\tProcessor Version: %s\n", dmi_string(h, p[0x10])); printf("\tVoltage: %d (Bit0 - 5v, Bit1 - 3.3v, Bit2 - 2.9v)\n", p[0x11]&0x7); printf("\tExternal Clock: %d MHz\n", p[0x12]+p[0x13]*0x100); printf("\tMax Speed: %d MHz\n", p[0x14]+p[0x15]*0x100); printf("\tCurrent Speed: %d MHz\n", p[0x16]+p[0x17]*0x100); printf("\tSerial Number: %s\n", dmi_string(h, p[0x20])); printf("\tAsset Tag: %s\n", dmi_string(h, p[0x21])); printf("\tPart Number: %s\n", dmi_string(h, p[0x22])); } else if (h->type == 17) { if (p[0xc]+p[0xd]*0x100 == 0) continue; printf("\nType %02d - [Memory]\n", h->type); printf("\tTotal Width: %d\n", p[0x8]); printf("\tData Width:%d\n", p[0xa]); printf("\tSize: %d MB\n", p[0xc]+p[0xd]*0x100); printf("\tSpeed: %dMHz\n", p[0x15]+p[0x16]*0x100); printf("\tBank Locator: %s\n", dmi_string(h, p[0x11])); printf("\tManufacturer: %s\n", dmi_string(h, p[0x17])); printf("\tSerial Number: %s\n", dmi_string(h, p[0x18])); printf("\tAsset Tag: %s\n", dmi_string(h, p[0x19])); printf("\tPart Number: %s\n", dmi_string(h, p[0x1A])); } p += h->length; while((*(WORD *)p)!=0) p++; p += 2; } getchar(); return 0; }
相關推薦
Windows 下讀取DMI資訊的方法
// wdmi.cpp : Defines the entry point for the console application. // Open source.... you can refer to below code.... #include "stdafx.h" #include #inclu
ruby在windows下讀取檔案的md5方法
最近專案需要讀取一批檔案的md5值,就用ruby提供的api生成 checksum = Digest::MD5.hexdigest(File.read(filename)} ) 然後提交給QA,細心的QA用WinMD5工具對比了一個檔案發現生成的MD5值竟然不同,後來
sphinx-for-chinese在windows下安裝與使用方法
用戶 同時 另一個 優化 exe tty 正常 計算機 clas sphinx-for-chinese的使用方法將使用 sphinx-for-chinese-2.2.1-dev-r4311-win32 為例子,目前我只找到最新的是這個版本2013.11.09發布。下載地址:
sphinx全文搜尋在windows下安裝與使用方法
sphinx-for-chinese的使用方法將使用 sphinx-for-chinese-2.2.1-dev-r4311-win32 為例子,目前我只找到最新的是這個版本2013.11.09釋出。 下載地址:http://sphinxsearchcn.github.io/ 下載完後解壓出來得到以下
windows 下GitHub的使用方法
1.首先去github官網註冊一個賬號,(如何註冊,聰明人都知道,這裡就省略了) 2.去https://desktop.github.com/這裡下載一個github桌面版 下載完成後,雙擊執行github,選擇第一個: 點選加號
windows 下 cudnn的安裝方法
下載cudnn的安裝檔案https://download.csdn.net/download/qq_33485434/10794010 將檔案解壓,例如解壓到d:\cuda\ 解壓後有三個子目錄:bin,include,lib 將bin目錄(例如 d:\cuda\bin)新增到環境變數
python在windows下安裝第三方模組方法
cmd下開啟你下載該包的路徑,例如我的是C:\python\other,執行cd C:\python\other CD到了該目錄下後,執行命令安裝指定包 例如我要安裝剛下載好的numpy-1.11.2+mkl-cp35-cp35m-win_amd64.whl 則執行以下命
推薦一款Windows下讀取 Linux檔案系統Ext4的最佳軟體 Paragon ExtFS
現在完全拋棄Windows還不現實,大家一般跑的是雙系統,所以常常就需要在Windows下訪問Linux的分割槽,一般為Ext4格式。 用過好幾款類似的軟體,都不太滿意,要麼只能讀不能寫,要麼寫操作經常有bug 只有 Paragon ExtFS 能完美的讀寫,並且使用很方便。 Paragon
windows下讀取配置檔案(.ini)
Windows系統中有很多.ini檔案,最重要的就是“System.ini”、“System32.ini”和“Win.ini”。該檔案主要存放使用者所做的選擇以及系統的各種引數。使用者可以通過修改INI檔案,來改變應用程式和系統的很多配置,如通訊埠的選擇等。在Windows
windows下安裝Laravel的方法
Laravel是近幾年國外團隊開發出來的一個比較新的框架,在效率和簡潔性上比之前的一些框架確實有很大的提升,而且自身帶了很多的外掛,所以可以作為小型團隊開發的首選。 那麼,如何如何安裝Laravel框架呢,Laravel和一些其它框架不同的地方也體現在它的安裝
Golang windows下交叉編譯的方法
Golang windows下交叉編譯的方法 在CMD命令列中編譯(示例編譯64位linux程式) set GOARCH=amd64 set GOOS=linux go build xxx.go 在windows10之前的系統版本上使用cmd命令列可以使用上述
Linux下檢視系統資訊方法總結
Linux下如何檢視系統啟動時間和執行時間1.檢視/proc/uptime檔案計算系統啟動時間: cat /proc/uptime 輸出: 5113396.94 575949.85第一數字即是系統已執行的時間5113396.94秒,運用系統工具date即可算出系統啟動時間
Linux和Windows下檢視環境變數方法對比(轉)
一、檢視所有環境變數的名稱和值: Linux下:export Windows下:set 二、根據名稱查該環境變數的值: Linux下:echo $環境變數名 如:echo $ORACLE_HOME Windows下:set環境變數名 如:set
Windows下Git的使用方法
在工作目錄下右鍵->Git Bash Here會開啟一個Git Bash視窗,執行ssh-keygen -t rsa生成自己的金鑰,金鑰預設儲存在C:\Users\<your name&
Android工程模式下讀取硬體資訊
Android工程模式下需要一個方便的途徑去訪問底層的硬體資訊,以方便軟體和測試同事更加簡單的知道硬體資訊;Android 從底層本質上說是 Linux,因此可以把 Android 當作 Linux 來訪問,從而達到訪問系統資訊的目的; 一:proc 檔案系
在Windows下讀取Ext4分割槽
本文介紹兩個能在 Windows 下讀取ext4分割槽的軟體。 第一個是 Ext2Read。它能檢視 ext2/3/4 分割槽並從中拷貝檔案和目錄,支援 LVM2 和 EXT4 extent ,以及遞迴拷貝整個目錄。 第二個是本站之前介紹過的 Ext2Fsd ,它是
Windows下檢視library(即.lib檔案)匯出函式或32、64位編譯等資訊的方法
開發人員都知道,檢視DLL或exe檔案匯出函式、依賴檔案等資訊,使用Depends即可,Depends.exe隨VC6.0平臺釋出。 但是,Depends卻不能想檢視靜態庫.lib檔案的相關資訊,那如果想 1)檢視.lib檔案資訊; 2)沒有安裝VC6.0環境,卻想檢視DL
Windows下Mongodb以服務形式啟動的方法
echo 方法 自己 驗證 etc mon 日誌 麻煩 服務器 這兩周做網站,自己搞定了服務器、數據庫和前端,接觸的知識非常多,為了防止以後忘記,特此記錄一下。 這篇隨筆主要記錄了Mongodb以服務形式啟動的方法。 1.mongodb的啟動參數 (1)指定mongodb的
windows下 sqlplus / as sysdba 報ora-12560的終極解決方法
原創 cmd home sysdba nbsp track software msd oca windows下 sqlplus / as sysdba 報ora-12560的終極解決方法 本文是原創文章。轉載請註明出處:http://blog.csdn.net
Windows下pycharm使用theano的方法
測試 打開 index 進入 clu min all warn 路徑 安裝theano前需要自行安裝Anaconda和PyCharm。在網上查了在PyCharm上安裝theano的方法,但是均遇到了一些問題,現將問題與解決方案介紹如下。 (一)第一種安裝方式 打開c