本帖最后由 locoman 于 2023-8-19 14:15 编辑
论坛中有一帖子《纯批处理获取硬件信息》,作者源码文件做得很好!!
http://www.bathome.net/viewthread.php?tid=38259
里面有很全很完整的硬件信息提取功能,一是,该bat文件内部有防修改加密措施,二是,我只需要提取显示器的硬件信息。
因此,我想对该bat文件有关显示器信息部分进行拆分剥离出来单独使用。
可是,我始终没有成功,在此,想请大佬帮我搞一下,以实现bat提取显示器硬件信息。
先谢谢了!!拜托!!
=================
只需要这个结果:
=================
关于显示器的详细信息如下:
型号 ........... : HWP3121
屏幕尺寸 ....... : 19 英寸
生产日期 ....... : 2015 年 第 49 周
屏幕大小 ....... : 43 厘米 × 24 厘米
像素密度 ....... : 96 Dpi
当前模式 ....... : 1600 x 900 (32 bit) (60 Hz)
==================
原帖子中源文件中源码(由于超过论坛限制,只贴出部分源码,完整的还敬请移步原帖子)
-------------------------------------- echo.关于显示器的详细信息如下:>>!File!
- echo.>>!File!
- for /f "tokens=3" %%i in ('Reg Query "HKLM\System\CurrentControlSet\Enum\Display\!5!\!6!\Device Parameters" /v "Edid" 2^>nul') do (
- set Edid=%%i
- )
- if "%Edid%" == "" (for /f "tokens=3" %%i in ('Reg Query "HKLM\System\CurrentControlSet\Enum\Display\!5!" /s 2^>nul ^|findstr /i "Edid"') do (set Edid=%%i))
- if "%DisplayName%" == "" set DisplayName=!NoGet!
- echo. 型号 ........... : %DisplayName%>>!File!
- echo.>>!File!
- if not "%Edid%" == "" (
- set Yeardata=!Edid:~34,2!
- set Weekdata=!Edid:~32,2!
- set Longdata=!Edid:~42,2!
- set Widedata=!Edid:~44,2!
- set /a Weekdata=0X!Weekdata!*1
- set /a Longdata=0X!Longdata!*1
- set /a Widedata=0X!Widedata!*1
- set /a Yeardata=0X!Yeardata!*1+1990
- call :Division !Longdata! 2.54 Longdata.in
- call :Division !Widedata! 2.54 Widedata.in
- call :Times !Longdata.in! !Longdata.in! Longdata.in
- call :Times !Widedata.in! !Widedata.in! Widedata.in
- call :Addition !Longdata.in! !Widedata.in! Diagonal
- set "Code=CreateObject("Scripting.FileSystemObject").GetStandardStream(1).Write(sqr(!Diagonal!))(close)"
- for /f "delims=" %%i in ('Mshta "Vbscript:!Code!"') do set Screen.In=%%i
- for /f "tokens=1,2 delims=." %%i in ("!Screen.In!") do (
- set Screen.In=%%i
- set Screen.Io=%%j
- )
- set Screen.Io=!Screen.Io:~0,1!
- if !Screen.Io! geq 7 set /a Screen.In=!Screen.In!+1
- echo. 屏幕尺寸 ....... : !Screen.In! 英寸>>!File!
- echo.>>!File!
- echo. 生产日期 ....... : !Yeardata! 年 第 !Weekdata! 周>>!File!
- echo.>>!File!
- echo. 屏幕大小 ....... : !Longdata! 厘米 × !Widedata! 厘米>>!File!
- echo.>>!File!
- )
- if not defined PixelsPerXLogicalInch (set PixelsPerXLogicalInch=!NoGet!) else set PixelsPerXLogicalInch=!PixelsPerXLogicalInch! Dpi
- echo. 像素密度 ....... : %PixelsPerXLogicalInch%>>!File!
- echo.>>!File!
- echo. 当前模式 ....... : %Resolution%>>!File!
- if not "%CD-ROM.Name%" == "无" (
- echo.>>!File!
- echo.>>!File!
- echo.关于光驱的详细信息如下:>>!File!
- echo.>>!File!
- echo. 列出所有光驱: >>!File!
- echo.>>!File!
- echo. 盘符 类型 型号 >>!File!
- echo.>>!File!
- for /f "skip=1 delims=" %%i in ('Wmic CdRom Get Name^,Drive^,Mediatype 2^>nul') do (
- set CdRom.0=%%i
- call :Exit
- if "!CdRom.0!" neq "" echo. !CdRom.0!>>!File!
- )
- )
- echo.>>!File!
复制代码
|