捐赠 | 广告 | 注册 | 发布 | 上传 | 关于我们    
  沪ICP备05001939号 DELPHI盒子 | 盒子论坛 | 盒子文章 | 盒子问答悬赏 | 最新更新 | 论坛检索 | 下载中心 | 高级搜索    
  精品专区 | 繁體中文 | 奖励公告栏 | 直通车账号登陆 | 关闭GOOGLE广告 | 临时留言    
盒子资源分类
全部展开 - 全部合拢
VBS在Delphi中的实现
关键字:VBS 脚本 ActiveX 硬件检测
来 自:原创
平 台:Win2k/XP/NT,Win2003 下载所需:0 火柴
深浅度:中级 完成时间:2007/12/18
发布者:tans 发布时间:2007/12/18
编辑器:DELPHI7 语  种:简体中文
分 类:应用软件 下载浏览:2872/18856
加入到我的收藏
下载错误报错
登陆以后才能下载
 用户名:
 密 码:
自动登陆(30天有效)
图片如果打不开,说明流量不够了,请稍候下载……
VBS在Delphi中的实现

要在Delphi中调用VBS首先需要在DELPHI集成环境中安装ActiveX控件。
要导入Activex控件,先选中Delphi菜单中的Component,选择导入ActiveX控制,安装Microsoft Script Control,就在Delphi环境中安装了ActiveX控件,然后在程序代码中加上这样一句:use MSScriptControl_TLB就可以调用VBS代码了。

程序中嵌入了VBS代码
'/功能:计算机硬件检测
On Error Resume Next
temp=0
'/set wshshell=wscript.createobject("wscript.shell")
'/wshshell.run ("%comspec% /c regsvr32 /s scrrun.dll"),0,True
'/wshshell.run ("%comspec% /c sc config winmgmt start= auto"),0,True
'/wshshell.run ("%comspec% /c net start winmgmt"),0

set wshshell=wscript.createobject("wscript.shell")
wshshell.run ("cmd /c regsvr32 /s scrrun.dll"),0,True
wshshell.run ("cmd /c sc config winmgmt start= auto"),0,True
wshshell.run ("cmd /c net start winmgmt"),0

Set WshNetwork = WScript.Createobject("WScript.Network")
computername=WshNetwork.ComputerName

set fso=createobject("scripting.filesystemobject")
'/tempfilter="\\192.168.0.250\tool$\机器配置\"& computername &".txt"
tempfilter="c:\pc.txt"
set tempfile=fso.createtextfile(tempfilter)

strComputer = "."
Set objWMIService = Getobject("winmgmts:\\" & strComputer & "\root\cimv2")
'主板
set board =objwmiservice.execQuery("select * from win32_baseboard")
for each item in board
board2="主板:" & item.Product
next
'CPU
set cpu =objwmiservice.execQuery("select * from win32_processor")
for each item in cpu
cpu2= "CPU:" & item.Name
next
'内存
Set colItems = objWMIService.ExecQuery("Select * from Win32_PhysicalMemory",,48)
For Each objItem in colItems
a=objitem.capacity/1048576
temp=temp+objitem.capacity
n=n+1
Next
memory=temp/1048576
if n=1 then
memory2= "内存: " & n & "条" &a&"M"
else
memory2= "内存: " & n & "条" &a&"M"&" 总计"&memory&"M"
end if
'硬盘
set disk =objwmiservice.execQuery("select * from win32_diskdrive")
for each item in disk
disk2= "硬盘: " & item.Model
next

'显卡
set video =objwmiservice.execQuery("select * from win32_videocontroller",,48)
for each item in video
video2= "显卡: " & item.Description
next
'网卡
Set colItems = objWMIService.ExecQuery("Select * from Win32_NetworkAdapter",,48)
For Each objItem in colItems
if (left(objItem.NetConnectionID,4)="本地连接") then
lanname=objItem.Name 
end if
Next
lan2="网卡: " & lanname

tempfile.writeline(board2)
tempfile.writeline(cpu2)
tempfile.writeline(memory2)
tempfile.writeline(disk2)
tempfile.writeline(video2)
tempfile.writeline(lan2)

程序运行后会生成 c:\pc.txt

主板:8I915PL-G
CPU:Intel(R) Pentium(R) 4 CPU 3.00GHz
内存: 1条512M
硬盘: USB Flash Disk USB Device
显卡: RADEON X300 Series Secondary
网卡: Marvell Yukon 88E8001/8003/8010 PCI Gigabit Ethernet Controller

运行后还有错误,后来者如有修改、完善请传一份给我。opencode@21cn.com
Google
 
本站原创作品,未经作者许可,严禁任何方式转载;转载作品,如果侵犯了您的权益,请联系我们
龙脉加密锁 15元起 Grid++Report 报表 申请支付@网
 相关文章
Data2SQL数据脚本生成器
142857 2008/3/18 下+1461/浏+10867 评+12
在Delphi程序中执行脚本 (VBS或者JScript)
kwbin 2007/12/28 下+2673/浏+19053 评+6
VBS在Delphi中的实现
tans 2007/12/18 下+2872/浏+18857 评+2
相关评论
共有评论2条 当前显示最后1条评论
wangquan77731 2007/12/19 11:31:09
不错,就是运行到最后报错。
我要发表评论 查看全部评论
 
  DELPHI盒子版权所有 1999-2023 V4.01 粤ICP备10103342号-1 更新RSS列表