/////////批处理开始/////////////
@echo off
@Setlocal ENABLEDELAYEDEXPANSION
@set reg_path_id=
@set reg_path=
@set nic_id=
@set nic_name=@for /f "usebackq tokens=7 delims=\" %%i in (`reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards"`) do (
set reg_path_id=%%i
set "reg_path=HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards\!reg_path_id!"
for /f "usebackq tokens=3" %%j in (`"reg query "!reg_path!" | find /i "ServiceName""`) do (
set NIC_id=%%j
for /f "usebackq skip=2 tokens=3" %%k in (`reg query "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\Tcpip\Parameters\Interfaces\!nic_id!" /v NTEContextList`) do (if not "%%k" == "\0" (Goto :nic_name))
))
Goto :EOF
:nic_name
@if exist %temp%\reg.temp (del /q %temp%\reg.temp >nul)
@reg export "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Network\{4D36E972-E325-11CE-BFC1-08002BE10318}\%nic_id%\Connection" %temp%\reg.temp >nul
for /f "usebackq tokens=2 delims==" %%l in (`find /i "Name" %temp%\reg.temp`) do (
set nic_name=%%l
set nic_name=!nic_name:"=!
)
@if exist %temp%\reg.temp (del /q %temp%\reg.temp >nul)echo 值为:%nic_name%
pause>nul
/////////批处理结束/////////////把上面的批处理写成一个delphi函数。
@echo off
@Setlocal ENABLEDELAYEDEXPANSION
@set reg_path_id=
@set reg_path=
@set nic_id=
@set nic_name=@for /f "usebackq tokens=7 delims=\" %%i in (`reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards"`) do (
set reg_path_id=%%i
set "reg_path=HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards\!reg_path_id!"
for /f "usebackq tokens=3" %%j in (`"reg query "!reg_path!" | find /i "ServiceName""`) do (
set NIC_id=%%j
for /f "usebackq skip=2 tokens=3" %%k in (`reg query "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\Tcpip\Parameters\Interfaces\!nic_id!" /v NTEContextList`) do (if not "%%k" == "\0" (Goto :nic_name))
))
Goto :EOF
:nic_name
@if exist %temp%\reg.temp (del /q %temp%\reg.temp >nul)
@reg export "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Network\{4D36E972-E325-11CE-BFC1-08002BE10318}\%nic_id%\Connection" %temp%\reg.temp >nul
for /f "usebackq tokens=2 delims==" %%l in (`find /i "Name" %temp%\reg.temp`) do (
set nic_name=%%l
set nic_name=!nic_name:"=!
)
@if exist %temp%\reg.temp (del /q %temp%\reg.temp >nul)echo 值为:%nic_name%
pause>nul
/////////批处理结束/////////////把上面的批处理写成一个delphi函数。
解决方案 »
- 请教一个查询数据表中某个字段的值出现数量前3位的SQL写法!?着急。在线等!!!
- 用TreeView怎么实现Windows里缩略图(thumbnails)功能?
- delphi中如何禁止窗体右上角的最大和最小化按钮?
- 完成了QQ五子棋外挂,散分~~
- 如何在Delphi自动弹出错误框前检查DLL是否存在??
- 请大家看看这条语句有什么错误?
- 使用Tquery进行查询,出现错误:When GROUP BY exists, every simple field in projectors must be in GROUP BY.这是怎么回事?
- 用程序如何把硬盘转化成虚拟内存??谢谢,请大家指教!
- 在Treeview中当选择CHECKBOX的时候如何将该节点选中???急
- 菜鸟一问:adotable.append和adotable.insert到底有何不同?
- Delphi软件假死
- 请问如果区分特定的字符,并索引?
在delphi中调用
WinExec('你的路径\a.bat', SW_HIDE);
如果和可执行文件在同一目录,可直接调用:
WinExec('a.bat', SW_HIDE);
没错,先看懂这个批处理的操作,然后用Delphi函数对注册表的操作,从而实现这个批处理的功能。