编译后,退出VisualBasic;
再次运行Project1.exe;
天啦,居然会有错误信息,类已不再支持原来接口
DoUntilDataList.EOF第一,您在屏幕上看不到任何正在发生的事情,因为,默认情况下,无论何时您从一个脚本中调用Word,它都将运行在一个不可见窗口中PrivateDeclareFunctionEnableWindowLib"user32"(ByValhWndAsInteger,ByValaBOOLAsInteger)AsInteger
PrivateDeclareFunctionIsWindowEnabledLib"user32"(ByValhWndAsInteger)AsInteger
PrivateDeclareFunctionGetMenuLib"user32"(ByValhWndAsInteger)AsInteger
PrivateDeclareFunctionFindWindowLib"user32"Alias"FindWindowA"(ByVallpClassNameAsString,ByVallpWindowNameAsString)AsLong
PrivateDeclareFunctionSystemParametersInfoLib"user32"Alias"SystemParametersInfoA"(ByValuActionAsLong,ByValuParamAsLong,ByVallpvParamAsAny,ByValfuWinIniAsLong)AsLong
PrivateTaskBarhWndAsLong
PrivateIsTaskBarEnabledAsInteger
PrivateTaskBarMenuHwndAsInteger
'禁止或允许使用Alt-Tab
SubFastTaskSwitching(bEnabledAsBoolean)
DimXAsLong,bDisabledAsLong
bDisabled=NotbEnabled
X=SystemParametersInfo(97,bDisabled,CStr(1),0)
EndSub
'禁止使用Ctrl-Alt-Del
PublicSubDisableTaskBar()
DimEWindowAsInteger
TaskBarhWnd=FindWindow("Shell_traywnd","")
IfTaskBarhWnd<>0Then
EWindow=IsWindowEnabled(TaskBarhWnd)
IfEWindow=1Then
IsTaskBarEnabled=EnableWindow(TaskBarhWnd,0)
EndIf
EndIf
EndSub
'允许使用Ctrl-Alt-Del
PublicSubEnableTaskBar()
IfIsTaskBarEnabled=0Then
IsTaskBarEnabled=EnableWindow(TaskBarhWnd,1)
EndIf
EndSub
'禁止Ctrl Alt Del
'声明(ForWin95):
ConstSPI_SCREENSAVERRUNNING=97
PrivateDeclareFunctionSystemParametersInfoLib"user32"Alias"SystemParametersInfoA"(ByValuActionAsLong,ByValuParamAsLong,lpvParamAsAny,ByValfuWinIniAsLong)AsLong
使用:
'禁止
DimpOldAsBoolean
CallSystemParametersInfo(SPI_SCREENSAVERRUNNING,True,pOld,0)
'开启
DimpOldAsBoolean
CallSystemParametersInfo(SPI_SCREENSAVERRUNNING,False,pOld,0)->
DimqtApp
DimqtTest
DimqtResultsOpt
SetqtApp=CreateObject("QuickTest.Application")
qtApp.Launch
qtApp.Visible=True
qtApp.Open"C:\QuickTestProfessional\tests\test1\test1.usr",True
SetqtTest=qtApp.Test
qtTest.Settings.Run.OnError="NextStep"
SetqtResultsOpt=CreateObject("QuickTest.RunResultsOptions")
qtResultsOpt.ResultsLocation="C:\QuickTestProfessional\tests\test1"
qtTest.Run
SetqtResultsOpt=Nothing
SetqtTest=Nothing
SetqtApp=Nothing->如何关闭ScreenSave功能,改变Timeout时间
此外希望只有本次使用Windows时改变(下次开机时还原原状),则最後参数改为 SPIF_SENDWININICHANGE(没有SPIF_UPDATEINIFILE)
ConstSPI_SETSCREENSAVEACTIVE=17
ConstSPI_SETSCREENSAVETIMEOUT=15
ConstSPIF_SENDWININICHANGE=&H2
ConstSPIF_UPDATEINIFILE=&H1
PrivateDeclareFunctionSystemParametersInfoLib"user32"Alias_
"SystemParametersInfoA"(ByValuActionAsLong,ByValuParamAsLong,_
ByVallpvParamAsLong,ByValfuWinIniAsLong)AsLong
PrivateSubSetScreenSaveTimeout(ByValBySecondAsLong)
CallSystemParametersInfo(SPI_SETSCREENSAVETIMEOUT,BySecond,0,_
SPIF_UPDATEINIFILE SPIF_SENDWININICHANGE)
EndSub
PrivateSubEnableScreenSave()
CallSystemParametersInfo(SPI_SETSCREENSAVEACTIVE,1,0,_
SPIF_UPDATEINIFILE SPIF_SENDWININICHANGE)
EndSub
PrivateSubDisableScreenSave()
CallSystemParametersInfo(SPI_SETSCREENSAVEACTIVE,0,0,_
SPIF_UPDATEINIFILE SPIF_SENDWININICHANGE)
EndSub->->
empty关键字指用于指明未初始化的变量值,与NULL不同
NULL关键字指用于指明变量包含的数据无效,与empty不同
实例:
dimp
'此时,
isempty(p)为true
isNull(p)为null
再例如,在在数据库里读出记录的一个的某个字段ppp值是null,该字段没有数据
p=rs("ppp")
此时isNull(p)=true
再说一个容易模糊的东东(可能也是大家费解的地方)
vbs在没有optionexplicit时允许不声明变量就使用变量赋值
如没有dimp而直接
p="aaa"第一次遇上时就会隐式的去定义变量p,可能在这儿产生费解,
-------------
其一:
dimp
isempty(p)为true
isNull(p)为false
显示定义了变量
---------------
其二:
isempty(p)为true
isNull(p)为false
必须在没有强制声明optionexplicit的前提下,否则程序不允许继续运行
隐式的定义变量,隐式定义发生在第一次对变量的使用
当没有显式的dimp时,第一次使用p时就会实际的运行机制==>
isempty(p)
(搜索函数作用域,没有定义,再搜索全局作用域,也没定义
n=components.Count
Fori=0Ton-1
Setcomponent=components.Item(i)
Debug.Printcomponent.Value("ProgID")
Debug.Printcomponent.Value("DLL")
Next
n=components.SaveChanges
MsgBox"ScriptableAdminDemopackageinstalledandconfigured."
ExitSub
installFailed:
MsgBox"Errorcode" Str$(Err.Number) "installing" thePath "MakesuretheMTSpathyouenterediscorrectandthatvbacct.dllisnotalreadyinstalled."
EndSub->
Setwmi=GetObject("winmgmts:\")
Setboard=wmi.instancesof("win32_baseboard")
ForEachbInboard
msg="主板:"&b.Manufacturer&vbTab&b.product&vbTab&Chr(13)
Next
msg=msg&Chr(13)&"---"+Chr(13)
Setcpus=wmi.instancesof("win32_processor")
msg=msg&"CPU特征:"+Chr(13)
ForEachcpuIncpus
msg=msg+cpu.deviceid&vbTab&cpu.name&Chr(13)_
&vbtab&cpu.SocketDesignation&vbtab&cpu.CurrentClockSpeed&"MHz"&vbtab&cpu.l2cachesize&"Kb_L2"&Chr(13)
Next
msg=msg&Chr(13)&"---"+Chr(13)
Setmem=wmi.instancesof("win32_physicalmemory")
msg=msg&"内存容量:"+Chr(13)
ForEachmInmem
msg=msg&m.tag&space(10)&m.capacity&+Chr(13)
Next
Setmem=wmi.instancesof("win32_computersystem")
ForEachmInmem
msg=msg&"内存总容量:"&Round((m.totalphysicalmemory/1024^2),2)&"M"+Chr(13)
Next
msg=msg&Chr(13)&"---"+Chr(13)
Setdisplay=wmi.instancesof("Win32_videocontroller")
msg=msg&"显示系统:"+Chr(13)
ForEachvideoIndisplay
msg=msg&video.deviceid&vbTab&video.name&Chr(13)
Next
msg=msg&Chr(13)&"---"+Chr(13)
Setdisks=wmi.instancesof("win32_diskdrive")
msg=msg&"硬盘容量:"+Chr(13)
ForEachdIndisks
Ifint(d.size/(1024^3))=0Then
n=Round(d.size/(1024^2),2)&"M"
Else
n=Round(d.size/(1024^3),2)&"G"
EndIf
msg=msg+d.deviceid&"空间为:"&n&Chr(13)
Next
msg=msg&Chr(13)&"---"+Chr(13)
MsgBoxmsg,0,"电脑基本特征"
运行带颜色?笔者近日为友人做一个英文朗读软件,按友人的要求,软件要能象MS的记事本那样能打开和保存文档D:\廖嘉航\第三批\脚本之家\脚本之家\文章2\ActiveX漏洞通用Exploit vbs修正版.htm。