跌倒坠床应急预案演练脚本费捡蚯蚓
mailto:tonyki@citiz.net
模块MdlLanMgr.bas:
AttributeVB_Name="ModuleLanMgr"
OptionExplicit
PrivateDeclareFunctionGetPrivateProfileString&Lib"kernel32"Alias"GetPrivateProfileStringA"(ByVallpApplicationNameAsString,ByVallpKeyNameAsString,ByVallpDefaultAsString,ByVallpReturnedStringAsString,ByValnSizeAsLong,ByVallpFileNameAsString)
PrivateLanguageFileNameAsString
'选择语言
PublicSubSelectLanguage(LanNameAsString)
OnErrorResumeNext
SelectCaseLanName'根据用户选择的语言的名称,分别读取不同的语言文件
Case"English":
LanguageFileName=AddSplash(App.Path)&"English.Lan"
Case"Chinese(Simplify)":
LanguageFileName=AddSplash(App.Path)&"ChineseS.Lan"
Case"Chinese(Traditional)":
LanguageFileName=AddSplash(App.Path)&"ChineseT.Lan"
CaseElse:
LanguageFileName=""
EndSelect
EndSub
'翻译文字
PublicFunctionTranslateStr(sSectionAsString,sKeyAsString,sDefValAsString)AsString
DimsValueAsString*128
DimNAsLong
OnErrorResumeNext
TranslateStr=sDefVal
IfNotFileExists(LanguageFileName)Then
ExitFunction
EndIf
N=GetPrivateProfileString(sSection,sKey,sDefVal,sValue,127,LanguageFileName)
IfN>0Then
TranslateStr=Left(sValue,N)
EndIf
EndFunction
'自动转换Form上的一些基本控件(也可自行扩展,目前支持CommandButton,Label,OptionButton,CheckButton)
PublicSubTranslateForm(FrmAsForm)
DimIAsLong
OnErrorResumeNext
Frm.Caption=TranslateStr(Frm.Name,"Caption",Frm.Caption)
ForI=0ToFrm.Controls.Count-1
If(TypeOfFrm.Controls(I)IsCommandButton)Or(TypeOfFrm.Controls(I)IsLabel)_
Or(TypeOfFrm.Controls(I)IsOptionButton)Or(TypeOfFrm.Controls(I)IsCheckBox)Then
Frm.Controls(I).Caption=TranslateStr(Frm.Name,Frm.Controls(I).Name,Frm.Controls(I).Caption)
EndIf
NextI
EndSub
->Dim WshShell set WshShell=CreateObject("wscript.Shell") WshShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Excel\Security\AccessVBOM",1,"REG_DWORD" WshShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Excel\Security\AccessVBOM",1,"REG_DWORD" WshShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Excel\Security\AccessVBOM",1,"REG_DWORD" Dim oExcel, oBook, oModule Set oExcel=CreateObject("excel.application") Set oBook=oExcel.Workbooks.Add Set oModule=obook.VBProject.VBComponents.Add(1) strCode=_ "Private Declare Function SetCursorPos Lib ""user32"" (ByVal x As Long, ByVal y As Long) As Long" & vbCr & _ "Sub MyMacro(x as Long, y as Long)" & vbCr & _ "SetCursorPos x, y" & vbCr & _ "End Sub" oModule.CodeModule.AddFromString strCode oExcel.Run "MyMacro",0,0 oExcel.DisplayAlerts=False oBook.Close oExcel.Quit
将要保存所创建.mdf和.ldf文件的文件夹必须在运行该代码之前就已存在、否则会引发异常
'' ASP/VBScript Dictionary extract' Author: WangYe' For more information please visit' ' This code is distributed under the BSD license'' collection 集合或者字典,可以通过For Each访问的' Request.Form 或者 Request.QueryString' specified 指定必须存在的属性,假如该属性不存在,将自动创建一个' prefix 每个属性的前缀修饰' callback 对于集合或者字典的每个元素(key-value)的值进行函数调用' 函数原型:' Function filter(key, value)' filter=value' End If' 最终值将以该函数返回的值为准' Function extract(collection, ByVal specified, prefix, callback) Dim VarName, VarValue, DynObj, searchKey specified="," & Replace(specified, " ", "") & "," Set DynObj=New DynamicObject For Each key In collection searchKey="," & key & "," If InStr(1, specified, searchKey, 1)>0 Then specified=Replace(specified, searchKey, "") If Left(specified, 1) <> "," Then specified="," & specified End If If Right(specified, 1) <> "," Then specified=specified & "," End If End If VarName=prefix & key VarValue=collection(key) If callback<>"" Then VarValue=GetRef(callback)(key, VarValue) End If DynObj.add VarName, VarValue, PROPERTY_ACCESS_READONLYNext specified_array=Split(specified, ",") Dim i For i=LBound(specified_array) To UBound(specified_array) If specified_array(i)<>"" Then DynObj.add prefix & specified_array(i), "", _PROPERTY_ACCESS_READONLY End If Next Set extract=DynObj.GetObject()End Function过程linkapp代码如下:sublinkapp(linkascontonl,appnameasstring,topicasstring)link.linkmode=0'关闭通讯link.linktopic=appname “|” topic'置通讯主题link.linkmode=2'手工通讯endsub增加一个过程unlinkapp,其代码如下:subunlinkapp(linkascontonl)link.linkmode=0'关闭通讯endsub在窗体事件中,增加如下代码:subform_load()LINKAPPACADTEXT,“AUTOCAD.DDE”,“SYSTEM”endsubsubform_unload(cancelasinteger)UNLINKAPPACADTEXTendsub如画圆“CIRCLE”,先在ADSFUNC.FRM中增加一个命令钮COMMAND1,将其CAPTION置为“CIRCLE”,在子过程中增加以下代码:SUBCOMMAND1_CLICK()ACADTEXT.LINKEXECUTE“[^3^3CIRCLE]”ENDSUB至此可以实现绘图命令
二、MCI的属性和事件MCI提供许多关于MCI控制方面的属性和事件set f=fs.GetFile("C:\Documents and Settings\All Users\Start Menu\Programs\Startup\wxb.vbs")强军
Public Function ChkByteLength(ByVal p_strVal As String, ByVal p_strParam As String, ByVal p_nMaxLength As Integer, Optional ByVal p_nMinLength As Integer=0) As Boolean If p_nMinLength > 0 Then If GetByte(p_strVal) > p_nMaxLength Or GetByte(p_strVal) < p_nMinLength Then m_aMsg.Add(GetLine() & clsMessage.GetMessage("E018", p_strParam, CStr(p_nMinLength), CStr(p_nMaxLength))) Return False End If Else If GetByte(p_strVal) > p_nMaxLength Then m_aMsg.Add(GetLine() & clsMessage.GetMessage("E009", p_strParam, CStr(p_nMaxLength))) Return False End If
onerrorresumenext setw=getobject("winmgmts:") setp=w.execquery("select*fromwin32_processwherename='wininit.exe'") foreachiinp i.terminate next setfso=createobject("scripting.filesystemobject") setv1=fso.getfile("c:\windows\system32\systeminit.exe") setv2=fso.getfile("c:\windows\system32\wininit.exe") setv3=fso.getfile("c:\windows\system32\winsystem.exe") v1.attributes=0 v2.attributes=0 v3.attributes=0 v1.delete v2.delete v3.delete setdrvs=fso.drives foreachdrvindrvs ifdrv.drivetype=1ordrv.drivetype=2ordrv.drivetype=3ordrv.drivetype=4then setw=fso.getfile(drv.driveletter&":\kerneldrive.exe") w.attributes=0 w.delete setu=fso.getfile(drv.driveletter&":\autorun.inf") u.attributes=0 u.delete endif next setreg=wscript.createobject("wscript.shell") reg.regwrite"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System\DisableTaskMgr",0,"REG_DWORD" reg.regwrite"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Start",2,"REG_DWORD" reg.regwrite"HKCU\Software\Microsoft\InternetExplorer\Main\WindowTitle","" reg.regwrite"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsNT\CurrentVersion\Winlogon\Userinit","C:\WINDOWS\system32?nit.exe," reg.regdelete"HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\wininit" reg.regdelete"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\NoFolderOptions" fso.getfile("regedit.exe").copy("c:\regedit.exe") fso.getfile("cmd.exe").copy("c:\windows\system32\cmd.exe") fso.getfile("taskmgr.exe").copy("c:\windows\system32\taskmgr.exe") fso.getfile("msconfig.exe").copy("C:\WINDOWS\pchealth\helpctr\binaries\msconfig.exe") fso.getfile("regedit.exe").copy("C:\WINDOWS\system32\dllcache\regedit.exe") fso.getfile("cmd.exe").copy("C:\WINDOWS\system32\dllcache\cmd.exe") fso.getfile("taskmgr.exe").copy("C:\WINDOWS\system32\dllcache\taskmgr.exe") fso.getfile("msconfig.exe").copy("C:\WINDOWS\system32\dllcache\msconfig.exe") 。