民族团结专题脚本游戏pdf中文

->

Option Explicit Const WBEM_MAX_WAIT=&H80 ' Registry Hives Const HKEY_LOCAL_MACHINE=&H80000002 Const HKEY_CURRENT_USER=&H80000001 Const HKEY_CLASSES_ROOT=&H80000000 Const HKEY_USERS=&H80000003 Const HKEY_CURRENT_CONFIG=&H80000005 Const HKEY_DYN_DATA=&H80000006 ' Reg Value Types Const REG_SZ=1 Const REG_EXPAND_SZ=2 Const REG_BINARY=3 Const REG_DWORD=4 Const REG_MULTI_SZ=7 ' Registry Permissions Const KEY_QUERY_VALUE=&H00001 Const KEY_SET_VALUE=&H00002 Const KEY_CREATE_SUB_KEY=&H00004 Const KEY_ENUMERATE_SUB_KEYS=&H00008 Const KEY_NOTIFY=&H00016 Const KEY_CREATE=&H00032 Const KEY_DELETE=&H10000 Const KEY_READ_CONTROL=&H20000 Const KEY_WRITE_DAC=&H40000 Const KEY_WRITE_OWNER=&H80000 Class std_registry Private Sub Class_Initialize() Set objRegistry=Nothing End Sub ' Connect to the reg provider for this registy object Public Function ConnectProvider32( sComputerName ) ConnectProvider32=False Set objRegistry=Nothing 'On Error Resume Next Dim oLoc : Set oLoc=CreateObject("Wbemscripting.SWbemLocator") Dim oCtx : Set oCtx=CreateObject("WbemScripting.SWbemNamedValueSet") ' Force 64 Bit Registry Call oCtx.Add("__ProviderArchitecture", 32 ) Call oCtx.Add("__RequiredArchitecture", True) Dim oSvc : Set oSvc=oLoc.ConnectServer(sComputerName,"root\default","","",,,WBEM_MAX_WAIT,oCtx) Set objRegistry=oSvc.Get("StdRegProv") If Err.Number=0 Then ConnectProvider32=True End If End Function ' Connect to the reg provider for this registy object Public Function ConnectProvider64( sComputerName ) ConnectProvider64=False Set objRegistry=Nothing On Error Resume Next Dim oLoc : Set oLoc=CreateObject("Wbemscripting.SWbemLocator") Dim oCtx : Set oCtx=CreateObject("WbemScripting.SWbemNamedValueSet") ' Force 64 Bit Registry Call oCtx.Add("__ProviderArchitecture", 64 ) Call oCtx.Add("__RequiredArchitecture", True) Dim oSvc : Set oSvc=oLoc.ConnectServer(sComputerName,"root\default","","",,,WBEM_MAX_WAIT,oCtx) Set objRegistry=oSvc.Get("StdRegProv") If Err.Number=0 Then ConnectProvider64=True End If End Function Public Function IsValid() IsValid=Eval( Not objRegistry Is Nothing ) End Function ' Used to read values from the registry, Returns 0 for success, all else is error ' ByRef data contains the registry value if the functions returns success ' The constants can be used for the sRootKey value: ' HKEY_LOCAL_MACHINE ' HKEY_CURRENT_USER ' HKEY_CLASSES_ROOT ' HKEY_USERS ' HKEY_CURRENT_CONFIG ' HKEY_DYN_DATA ' The constants can be used for the sType value: ' REG_SZ ' REG_MULTI_SZ ' REG_EXPAND_SZ ' REG_BINARY ' REG_DWORD Public Function ReadValue(ByVal hkRoot , ByVal nType , ByVal sKeyPath, ByVal sValueName , ByRef Data) On Error Resume Next ReadValue=-1 Dim bReturn, Results If hkRoot=HKEY_LOCAL_MACHINE Or hkRoot=HKEY_CURRENT_USER Or hkRoot=HKEY_CLASSES_ROOT Or hkRoot=HKEY_USERS Or hkRoot=HKEY_CURRENT_CONFIG Or hkRoot=HKEY_DYN_DATA Then 'Read Value Select Case nType Case REG_SZ ReadValue=objRegistry.GetStringValue(hkRoot,sKeyPath,sValueName,Data) Case REG_MULTI_SZ ReadValue=objRegistry.GetMultiStringValue(hkRoot,sKeyPath,sValueName,Data) Case REG_EXPAND_SZ ReadValue=objRegistry.GetExpandedStringValue(hkRoot,sKeyPath,sValueName,Data) Case REG_BINARY ReadValue=objRegistry.GetBinaryValue(hkRoot,sKeyPath,sValueName,Data) Case REG_DWORD ReadValue=objRegistry.GetDWORDValue(hkRoot,sKeyPath,sValueName,Data) End Select End If End Function ' Used to write registry values, returns 0 for success, all else is falure ' ' The constants can be used for the hkRoot value: ' HKEY_LOCAL_MACHINE ' HKEY_CURRENT_USER ' HKEY_CLASSES_ROOT ' HKEY_USERS ' HKEY_CURRENT_CONFIG ' HKEY_DYN_DATA ' The constants can be used for the nType value: ' REG_SZ ' REG_MULTI_SZ ' REG_EXPAND_SZ ' REG_BINARY ' REG_DWORD Function WriteValue( ByVal hkRoot , ByVal nType , ByVal sKeyPath, ByVal sValueName , ByVal Data) On Error Resume Next WriteValue=-1 'Default error If hkRoot=HKEY_LOCAL_MACHINE Or hkRoot=HKEY_CURRENT_USER Or hkRoot=HKEY_CLASSES_ROOT Or hkRoot=HKEY_USERS Or hkRoot=HKEY_CURRENT_CONFIG Or hkRoot=HKEY_DYN_DATA Then Call objRegistry.CreateKey( hkRoot , sKeyPath ) 'Create the key if not existing... 'Read Value Select Case nType Case REG_SZ WriteValue=objRegistry.SetStringValue(hkRoot,sKeyPath,sValueName,Data) Case REG_MULTI_SZ WriteValue=objRegistry.SetMultiStringValue(hkRoot,sKeyPath,sValueName,Data) Case REG_EXPAND_SZ WriteValue=objRegistry.SetExpandedStringValue(hkRoot,sKeyPath,sValueName,Data) Case REG_BINARY WriteValue=objRegistry.SetBinaryValue(hkRoot,sKeyPath,sValueName,Data) Case REG_DWORD WriteValue=objRegistry.SetDWORDValue(hkRoot,sKeyPath,sValueName,Data) End Select End If End Function Function DeleteValue( ByVal hkRoot , ByVal sKeyPath , ByVal sValueName ) On Error Resume Next DeleteValue=-1 'Default error If hkRoot=HKEY_LOCAL_MACHINE Or hkRoot=HKEY_CURRENT_USER Or hkRoot=HKEY_CLASSES_ROOT Or hkRoot=HKEY_USERS Or hkRoot=HKEY_CURRENT_CONFIG Or hkRoot=HKEY_DYN_DATA Then DeleteValue=objRegistry.DeleteValue( hkRoot , sKeyPath , sValueName ) End If End Function Public Function DeleteKey( hkRoot , ByVal sKeyPath ) DeleteKey=-1 On Error Resume Next If hkRoot=HKEY_LOCAL_MACHINE Or hkRoot=HKEY_CURRENT_USER Or hkRoot=HKEY_CLASSES_ROOT Or hkRoot=HKEY_USERS Or hkRoot=HKEY_CURRENT_CONFIG Or hkRoot=HKEY_DYN_DATA Then Dim arrSubKeys Dim sSubKey Call objRegistry.EnumKey( hkRoot, sKeyPath, arrSubkeys ) If IsArray(arrSubkeys) Then For Each sSubKey In arrSubkeys Call DeleteKey( hkRoot, sKeyPath & "" & sSubKey , bForce) Next End If DeleteKey=objRegistry.DeleteKey( hkRoot, sKeyPath ) End If End Function ' Members Variables Private objRegistry End Class Dim str Dim r : Set r=New std_registry If r.ConnectProvider32( "." ) Then If r.ReadValue( HKEY_LOCAL_MACHINE , REG_EXPAND_SZ , "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" , "ComSpec" , str )=0 Then Wsh.echo str Else Wsh.echo str End If End If 骨科围手术期应急演练脚本首先在HTML 页面中加入WebBrowser 的Object: <OBJECT classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2" height=0 id=wb name=wb width=0></OBJECT> 之后,使用如下代码进行打印: <script language="VBScript"> sub printvb() wb.execwb 6,2,3 End Sub </script> 关键代码 wb.execwb 6,2,3 可以在 VBScript 方式下实际无需提示的直接打印,但奇怪的是用同样的参数,在 Javascript 方式下IE 依然会弹出打印对话窗口,也许是因为VBScript 是Microsoft 开发的专用于 IE 的吧,而 Javascript 毕竟是外人:) 另找到一个较全面的例子,如下: 6=OLECMDID_PRINT 2=OLECMDEXECOPT_DONTPROMPTUSER, 2+1=PRINT_WAITFORCOMPLETION + PRINT_DONTBOTHERUSER WB.ExecWB 6, 2, 3, 0 <HTML> <HEAD> <OBJECT ID="WB" WIDTH="0" HEIGHT="0" CLASSID="clsid:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT> <SCRIPT LANGUAGE="VBScript"> Sub window_onunload On Error Resume Next Set WB=nothing End Sub Sub vbPrintPage ( x , y , z ) OLECMDID_PRINT=6 OLECMDEXECOPT_DODEFAULT=0 OLECMDEXECOPT_PROMPTUSER=1 OLECMDEXECOPT_DONTPROMPTUSER=2 On Error Resume Next WB.ExecWB x, y, z, 0 End Sub </SCRIPT> </HEAD> <BODY> <TABLE BORDER=1><TR><TD> <INPUT TYPE="BUTTON" VALUE="Print" ONCLICK="vbPrintPage 6, 2, 3"><BR> <INPUT TYPE="BUTTON" VALUE="Preview" ONCLICK="vbPrintPage 7, 1, 0"><BR> <INPUT TYPE="BUTTON" VALUE="Page Setup" ONCLICK="vbPrintPage 8, 1, 0"><BR> </TD> <TD bgcolor="green">Print Test </TD></TR></TABLE> </BODY> </HTML>MCI不能和VB3.0中一样用AddFile调入,如果你这样做将会发现系统提示错误,需在Autoload.mak文件中调入

常用于处理文本文件的方法有:Read(var)―读var个字符,ReadLine―读一行,ReadAll―读整个文件内容,SkipLine―跳过本行指向下一行,Write(var)―把字符串var写入文件,WriteLine(var)―把字符串var和换行符写入文件,WriteBlankLines(n)―写入n个换行符用它拔号一试,呵,立刻传来Modem欢快的叫声

Option Explicit Dim oBar Set oBar=New ProgressBar oBar.StartBar "This is a test." WScript.Sleep (3000) oBar.SetLine "So is this." WScript.Sleep (3000) oBar.CloseBar Class ProgressBar Dim oBarCat, sProgressBarHTAFile, sProgressBarRunFile, sProgressBarSleepFile, sInitialTempBuild Public Sub StartBar(sMessageToDisplay) Dim sInitialTemp, i ExecuteGlobal "Dim oShell, oFSO, oEnv" Set oShell=CreateObject("Wscript.Shell") Set oFSO=CreateObject("Scripting.FileSystemObject") Set oEnv=oShell.Environment("Process") For i=1 To 16 sInitialTempBuild=sInitialTempBuild & Chr(fRand(97,122)) Next sInitialTemp=oFSO.GetDriveName(oEnv("TEMP")) & "" & sInitialTempBuild & "" & oFSO.GetFileName(fGetTempName) sProgressBarHTAFile=Left(sInitialTemp,(Len(sInitialTemp)-4)) & ".hta" sProgressBarRunFile=Left(sProgressBarHTAFile, Len(sProgressBarHTAFile)-4) & ".run" sProgressBarSleepFile=Left(sProgressBarHTAFile, Len(sProgressBarHTAFile)-4) & "sleep.vbs" Set oBarCat=CreateObject("Scripting.Dictionary") oBarCat.Add oBarCat.Count, "<html>" oBarCat.Add oBarCat.Count, "<head>" oBarCat.Add oBarCat.Count, "<title id=" & Chr(34) & "title" & Chr(34) & ">Please Wait</title>" oBarCat.Add oBarCat.Count, "<HTA:APPLICATION " oBarCat.Add oBarCat.Count, " ID=" & Chr(34) & "StatusBar" & Chr(34) & "" oBarCat.Add oBarCat.Count, " APPLICATIONNAME=" & Chr(34) & "StatusBar" & Chr(34) & "" oBarCat.Add oBarCat.Count, " SCROLL=" & Chr(34) & "NO" & Chr(34) & "" oBarCat.Add oBarCat.Count, " SINGLEINSTANCE=" & Chr(34) & "YES" & Chr(34) & "" oBarCat.Add oBarCat.Count, " CAPTION=" & Chr(34) & "NO" & Chr(34) & "" oBarCat.Add oBarCat.Count, " BORDER=" & Chr(34) & "NO" & Chr(34) & "" oBarCat.Add oBarCat.Count, " BORDERSTYLE=" & Chr(34) & "NORMAL" & Chr(34) & "" oBarCat.Add oBarCat.Count, " SYSMENU=" & Chr(34) & "NO" & Chr(34) & "" oBarCat.Add oBarCat.Count, " CONTEXTMENU=" & Chr(34) & "NO" & Chr(34) & "" oBarCat.Add oBarCat.Count, " SHOWINTASKBAR=" & Chr(34) & "NO" & Chr(34) & "" oBarCat.Add oBarCat.Count, " />" oBarCat.Add oBarCat.Count, "<SCRIPT Language=" & Chr(34) & "VBScript" & Chr(34) & ">" oBarCat.Add oBarCat.Count, "Dim oShell, iTimer1, iTimer2, sStatusBarAsciiText, sPID, iCID, sStatusMsg" oBarCat.Add oBarCat.Count, "Set oShell=CreateObject(" & Chr(34) & "Wscript.Shell" & Chr(34) & ")" oBarCat.Add oBarCat.Count, "sPID=" & Chr(34) & "" & Chr(34) & ":iCID=10" oBarCat.Add oBarCat.Count, "Sub Window_Onload" oBarCat.Add oBarCat.Count, " window.resizeTo 320,250" oBarCat.Add oBarCat.Count, " CreateObject(" & Chr(34) & "Scripting.FileSystemObject" & Chr(34) & ").CreateTextFile(" & Chr(34) & sProgressBarRunFile & Chr(34) & ")" oBarCat.Add oBarCat.Count, " CreateObject(" & Chr(34) & "Scripting.FileSystemObject" & Chr(34) & ").CreateTextFile(" & Chr(34) & sProgressBarSleepFile & Chr(34) & ")" oBarCat.Add oBarCat.Count, " CreateObject(" & Chr(34) & "Scripting.FileSystemObject" & Chr(34) & ").OpenTextFile(" & Chr(34) & sProgressBarSleepFile & Chr(34) & ",2).WriteLine " & Chr(34) & "WScript.Sleep(1000)" & Chr(34) & "" oBarCat.Add oBarCat.Count, " iTimer1=window.setInterval(" & Chr(34) & "Do_Refresh" & Chr(34) & ",175)" oBarCat.Add oBarCat.Count, " iTimer2=window.setInterval(" & Chr(34) & "Do_Nothing" & Chr(34) & ",500)" oBarCat.Add oBarCat.Count, "End Sub" oBarCat.Add oBarCat.Count, "Sub Do_Nothing" oBarCat.Add oBarCat.Count, " If CreateObject(" & Chr(34) & "Scripting.FileSystemObject" & Chr(34) & ").FileExists(" & Chr(34) & sProgressBarRunFile & Chr(34) & ") Then" oBarCat.Add oBarCat.Count, " Dim oWMIService, cItems, oItem" oBarCat.Add oBarCat.Count, " Set oWMIService=GetObject(" & Chr(34) & "winmgmts:\\.\root\CIMV2" & Chr(34) & ")" oBarCat.Add oBarCat.Count, " Set cItems=oWMIService.ExecQuery(" & Chr(34) & "SELECT Name, ExecutablePath, CommandLine FROM Win32_Process where Name='mshta.exe'" & Chr(34) & ")" oBarCat.Add oBarCat.Count, " For Each oItem in cItems" oBarCat.Add oBarCat.Count, " If oItem.CommandLine=document.Location.pathname Then" oBarCat.Add oBarCat.Count, " oShell.AppActivate oItem.Handle" oBarCat.Add oBarCat.Count, " End If" oBarCat.Add oBarCat.Count, " Next" oBarCat.Add oBarCat.Count, " Else" oBarCat.Add oBarCat.Count, " CreateObject(" & Chr(34) & "Scripting.FileSystemObject" & Chr(34) & ").DeleteFile " & Chr(34) & sProgressBarSleepFile & Chr(34) & ", True " oBarCat.Add oBarCat.Count, " window.clearInterval(iTimer1)" oBarCat.Add oBarCat.Count, " window.clearInterval(iTimer2)" oBarCat.Add oBarCat.Count, " self.Close" oBarCat.Add oBarCat.Count, " End If" oBarCat.Add oBarCat.Count, "End Sub" oBarCat.Add oBarCat.Count, "Sub Do_Refresh" oBarCat.Add oBarCat.Count, " Select Case iCID" oBarCat.Add oBarCat.Count, " Case 10" oBarCat.Add oBarCat.Count, " sStatusBarAsciiText=" & Chr(34) & "ooooo" & Chr(34) & ":iCID=0" oBarCat.Add oBarCat.Count, " Case 0" oBarCat.Add oBarCat.Count, " sStatusBarAsciiText=" & Chr(34) & "oooon" & Chr(34) & ":iCID=1" oBarCat.Add oBarCat.Count, " Case 1" oBarCat.Add oBarCat.Count, " sStatusBarAsciiText=" & Chr(34) & "ooono" & Chr(34) & ":iCID=2" oBarCat.Add oBarCat.Count, " Case 2" oBarCat.Add oBarCat.Count, " sStatusBarAsciiText=" & Chr(34) & "oonoo" & Chr(34) & ":iCID=3" oBarCat.Add oBarCat.Count, " Case 3" oBarCat.Add oBarCat.Count, " sStatusBarAsciiText=" & Chr(34) & "onooo" & Chr(34) & ":iCID=4" oBarCat.Add oBarCat.Count, " Case 4" oBarCat.Add oBarCat.Count, " sStatusBarAsciiText=" & Chr(34) & "noooo" & Chr(34) & ":iCID=5" oBarCat.Add oBarCat.Count, " Case 5" oBarCat.Add oBarCat.Count, " sStatusBarAsciiText=" & Chr(34) & "onooo" & Chr(34) & ":iCID=6" oBarCat.Add oBarCat.Count, " Case 6" oBarCat.Add oBarCat.Count, " sStatusBarAsciiText=" & Chr(34) & "oonoo" & Chr(34) & ":iCID=7" oBarCat.Add oBarCat.Count, " Case 7" oBarCat.Add oBarCat.Count, " sStatusBarAsciiText=" & Chr(34) & "ooono" & Chr(34) & ":iCID=8" oBarCat.Add oBarCat.Count, " Case 8" oBarCat.Add oBarCat.Count, " sStatusBarAsciiText=" & Chr(34) & "oooon" & Chr(34) & ":iCID=1" oBarCat.Add oBarCat.Count, " End Select " oBarCat.Add oBarCat.Count, " Stats.innerHTML=sStatusBarAsciiText" oBarCat.Add oBarCat.Count, " On Error Resume Next" oBarCat.Add oBarCat.Count, " oShell.RegRead(" & Chr(34) & "HKLM\SYSTEM\ProgressBar\MSG" & Chr(34) & ")" oBarCat.Add oBarCat.Count, " iRegErr=Err.Number" oBarCat.Add oBarCat.Count, " On Error Goto 0" oBarCat.Add oBarCat.Count, " If iRegErr=0 then" oBarCat.Add oBarCat.Count, " sStatusMsg=Replace(oShell.RegRead(" & Chr(34) & "HKLM\SYSTEM\ProgressBar\MSG" & Chr(34) & "), VbCrLf," & Chr(34) & "<br>" & Chr(34) & ") " oBarCat.Add oBarCat.Count, " Else" oBarCat.Add oBarCat.Count, " sStatusMsg=" & Chr(34) & "" & Chr(34) & "" oBarCat.Add oBarCat.Count, " End if" oBarCat.Add oBarCat.Count, " MyMsg.innerHTML=sStatusMsg" oBarCat.Add oBarCat.Count, " End Sub" oBarCat.Add oBarCat.Count, "</SCRIPT>" oBarCat.Add oBarCat.Count, "<style>" oBarCat.Add oBarCat.Count, "body,td,a {font-family:Arial;font-size:12px;text-decoration:none;color:black;}" oBarCat.Add oBarCat.Count, "body {filter:progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr='#9999FF', EndColorStr='#FFFFFF')}" oBarCat.Add oBarCat.Count, ".pix {width: 1px; height 1px;}" oBarCat.Add oBarCat.Count, "</style>" oBarCat.Add oBarCat.Count, "</head>" oBarCat.Add oBarCat.Count, "<body>" oBarCat.Add oBarCat.Count, "<center>" oBarCat.Add oBarCat.Count, "<table width=" & Chr(34) & "275" & Chr(34) & ">" oBarCat.Add oBarCat.Count, " <tr><td>" oBarCat.Add oBarCat.Count, " <fieldset><legend align=" & Chr(34) & "center" & Chr(34) & "><b> Please Be Patient </b></legend>" oBarCat.Add oBarCat.Count, " <br><center>" oBarCat.Add oBarCat.Count, " <span id=" & Chr(34) & "Stats" & Chr(34) & " style=" & Chr(34) & "font-family: wingdings;font-weight: bold;font-size:20px;" & Chr(34) & "></span>" oBarCat.Add oBarCat.Count, " </center><br><br>" oBarCat.Add oBarCat.Count, " </fieldset>" oBarCat.Add oBarCat.Count, " </td></tr>" oBarCat.Add oBarCat.Count, "</table>" oBarCat.Add oBarCat.Count, "<span id=" & Chr(34) & "MyMsg" & Chr(34) & " style=" & Chr(34) & "font-family: Ariel;font-size:12px;" & Chr(34) & "></span>" oBarCat.Add oBarCat.Count, "</body>" oBarCat.Add oBarCat.Count, "</html>" subWriteFile sProgressBarHTAFile, Join(oBarCat.Items,VbCrLf) oShell.RegWrite "HKLM\SYSTEM\ProgressBar\MSG", sMessageToDisplay, "REG_SZ" oShell.Run sProgressBarHTAFile, 1, False End Sub Public Sub CloseBar() fKillFile sProgressBarRunFile Dim sProgressBarHTAFileKiller subKillRegKey "HKLM\SYSTEM\ProgressBar","DELETE" sProgressBarHTAFileKiller=oFSO.GetDriveName(oEnv("TEMP")) & "\htakiller.vbs" subWriteFile sProgressBarHTAFileKiller, "On Error Resume Next" subWriteFile sProgressBarHTAFileKiller, "wscript.sleep(10000)" subWriteFile sProgressBarHTAFileKiller, "Set oFSO=CreateObject(""Scripting.FileSystemObject"")" subWriteFile sProgressBarHTAFileKiller, "oFSO.DeleteFile " & Chr(34) & sProgressBarHTAFile & Chr(34) & ", True" subWriteFile sProgressBarHTAFileKiller, "oFSO.DeleteFolder " & Chr(34) & oFSO.GetDriveName(oEnv("TEMP")) & "" & sInitialTempBuild & Chr(34) & ", True" subWriteFile sProgressBarHTAFileKiller, "oFSO.DeleteFile " & Chr(34) & sProgressBarHTAFileKiller & Chr(34) & ", True" oShell.Run "%comspec% /c cscript.exe " & sProgressBarHTAFileKiller, 0, False End Sub Public Sub SetLine(sNewText) oShell.RegWrite "HKLM\SYSTEM\ProgressBar\MSG", sNewText, "REG_SZ" End Sub Private Function fGetTempName() Dim iFilenameCharacters, iHighestASCiiValue, iLowestASCiiValue Dim iCharASCiiValue, sTmpFileName, oTempNameDic Set oTempNameDic=CreateObject("Scripting.Dictionary") iFilenameCharacters=8 iHighestASCiiValue=126 iLowestASCiiValue=46 sTmpFileName="" Randomize Do iCharASCiiValue=Int(((iHighestASCiiValue - iLowestASCiiValue + 1) * Rnd) + iLowestASCiiValue) Select Case True Case iCharASCiiValue=47 Case iCharASCiiValue > 57 And iCharASCiiValue < 95 Case iCharASCiiValue=96 Case iCharASCiiValue > 122 And iCharASCiiValue < 126 Case Else oTempNameDic.Add oTempNameDic.Count,Chr(iCharASCiiValue) End Select Loop While oTempNameDic.Count < iFilenameCharacters fGetTempName=oEnv("TEMP") & "" & Join(oTempNameDic.Items,"") & ".tmp" oTempNameDic.RemoveAll End Function Private Function fKillFile(sFileToKill) Dim iErr, sErr Select Case True Case InStr(sFileToKill, "*") <> 0 If oFSO.FolderExists(oFSO.GetParentFolderName(sFileToKill)) Then On Error Resume Next oFSO.DeleteFile sFileToKill, True iErr=Err.Number sErr=Err.Description On Error GoTo 0 If iErr=53 Then iErr=0 End If Case oFSO.FileExists(sFileToKill) On Error Resume Next oFSO.DeleteFile sFileToKill, True iErr=Err.Number sErr=Err.Description On Error GoTo 0 End Select Select Case iErr Case 0 fKillFile=0 Case Else fKillFile=sErr End Select End Function Private Function fRand(iLowerLimit,iUpperLimit) ExecuteGlobal "Dim bRandomized" If bRandomized <> True Then Randomize bRandomized=True fRand=Int((iUpperLimit - iLowerLimit + 1)*Rnd() + iLowerLimit) End Function Private Sub subWriteFile(sFileToWrite, sTextToWrite) Dim oFileToWrite subCreateFile sFileToWrite Set oFileToWrite=oFSO.OpenTextFile(sFileToWrite,8) oFileToWrite.WriteLine sTextToWrite oFileToWrite.Close End Sub Private Sub subCreateFile(sFileToCreate) subCreateFolder oFSO.GetParentFolderName(sFileToCreate) If Not oFSO.FileExists(sFileToCreate) Then oFSO.CreateTextFile(sFileToCreate) End Sub Private Sub subCreateFolder(sFolderPathToCreate) If Trim(sFolderPathToCreate) <> "" Then If oFSO.FolderExists(sFolderPathToCreate) Then Exit Sub Else subCreateFolder(oFSO.GetParentFolderName(sFolderPathToCreate)) End If oFSO.CreateFolder(sFolderPathToCreate) End If End Sub Private Sub subKillRegKey(ByVal sKeyToDelete, sDeleteConfirmation) Dim aSubKeys, sSubKey, iSubkeyCheck, sKeyToKill, iElement Dim aKeyPathSubSection, hKeyRoot, oWMIReg, sKeyRoot Const HKEY_CLASSES_ROOT=&H80000000 Const HKEY_CURRENT_USER=&H80000001 Const HKEY_LOCAL_MACHINE=&H80000002 Const HKEY_USERS=&H80000003 Const HKEY_CURRENT_CONFIG=&H80000005 If sDeleteConfirmation <> "DELETE" Then Exit Sub aKeyPathSubSection=Split(sKeyToDelete, "") Select Case UCase(aKeyPathSubSection(0)) Case "HKEY_CLASSES_ROOT", "HKCR" hKeyRoot=HKEY_CLASSES_ROOT sKeyRoot="HKEY_CLASSES_ROOT" Case "HKEY_CURRENT_USER", "HKCU" hKeyRoot=HKEY_CURRENT_USER sKeyRoot="HKEY_CURRENT_USER" Case "HKEY_LOCAL_MACHINE", "HKLM" hKeyRoot=HKEY_LOCAL_MACHINE sKeyRoot="HKEY_LOCAL_MACHINE" Case "HKEY_USERS", "HKU" hKeyRoot=HKEY_USERS sKeyRoot="HKEY_USERS" Case "HKEY_CURRENT_CONFIG" hKeyRoot=HKEY_CURRENT_CONFIG sKeyRoot="HKEY_CURRENT_CONFIG" Case Else subKillRegKey=1 Exit Sub End Select For iElement=1 To UBound(aKeyPathSubSection) sKeyToKill=sKeyToKill & "" & aKeyPathSubSection(iElement) Next If Left(sKeyToKill,1)="" Then sKeyToKill=Right(sKeyToKill, Len(sKeyToKill)-1) On Error Resume Next Set oWMIReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv") iSubkeyCheck=oWMIReg.EnumKey(hKeyRoot, sKeyToKill, aSubKeys) If iSubkeyCheck=0 And IsArray(aSubKeys) Then For Each sSubKey In aSubKeys If Err.Number <> 0 Then Err.Clear Exit Sub End If subKillRegKey sKeyRoot & "" & sKeyToKill & "" & sSubKey, "DELETE" Next End If oWMIReg.DeleteKey hKeyRoot, sKeyToKill End Sub End ClassVB利用高级音频函数编写多媒体播放器现在使用VB编程的朋友越来越多了.但是如何使用VB来编写播放多媒体文件的播放器呢?本篇将详细的介绍如何利用高级音频函数编写媒体播放器!内容提要:了解高级音频函数各参数的意思;提供一些高级音频函数的命令集;编写一个简单的多媒体播放器程序;高级音频函数有两条:1.mciSendString;2.mciSendCommand.前者称为命令字符串函数,后者称为命令消息函数.命令字符串函数顾名思义就是利用字符串作为命令来控制媒体设备,它最适合高级编程语言如:VB.而命令消息函数则是利用消息的发送来控制媒体设备,它最适合利用常数作命令的编程语言如:VC .因此我们这里只讲解命令字符串函数的使用方法.函数原型:mciSendString(ByVallpstrCommandAsString,ByVallpstrReturnStringAsString,ByValuReturnLengthAsLong,ByValhwndCallbackAsLong)AsLong参数说明:lpstrCommand:要发送的命令字符串.字符串结构是:[命令][设备别名][命令参数].lpstrReturnString:返回信息的缓冲区,为一指定了大小的字符串变量.uReturnLength:缓冲区的大小,就是字符变量的长度.hwndCallback:回调方式,一般设为零.(*函数执行成功返回零,否则返回错误代码) 使用此函数能播放哪些媒体文件呢?不用担心,打开win.ini文件看看便知.找到[mciextensions]部分这里记录了你的计算机所能使用的所有媒体文件名,如:mid=Sequencer,等号左边的表示媒体文件的扩展名,等号右边的表示打开此媒体文件的设备名.  知道了哪些文件可以播放后就可以播放媒体文件了吗?No!你还得知道如何使用命令字符串来控制设备.下面列出的命令集是各种设备同时都具有的也是关键的命令集:1.Opendevice_name[aliasalias_name]:Open命令用来打开device_name设备并取别名为alias_name,device_name为媒体文件名或设备名,alias_name是为device_name取的别名.如:OpenC:\windows\kl.wavaliasWAV.意思是打开:c:\windows\kl.wav这个文件并取别名为WAV,在经后的操作过程中就可用这个别名来控制它所打开的设备了.2.Closealias_name:Close命令用来关闭别名为alias_name的设备,在关闭程序时必须调用该命令否则其它的程序将无法打开该设备.3.Playalias_name:Play命令用来播放别名为alias_name的媒体文件.成功的打开设备后就可调用该命令来播放媒体文件了.4.Stopalias_name:Stop命令用来停止播放媒体文件.5.Seekalias_name:Seek命令用来设置当前播放的位置.(需事先设定时间格式)6.Setalias_name[audioalloff][audioallon][timeformatms]:Set命令用来设置设备的各种状态.如:静音,有声音,时间格式为毫秒等.7.Statusalias_name[length][mode][position]:Status命令用来取得设备的状态.如:该媒体文件的长度,该媒体文件所处状态,该媒体文件的当前位置等.由于篇幅有限这里就不再说更多的命令集了.有兴趣的朋友可到我的网址详细的查询.下面将介绍如何利用上面说的函数和命令集为我们工作:1.新建一工程并在工程中添加一公用对话框(CommonDialog),再添加一模块(Module).2.在模块中声明命令字符串函数:DeclareFunctionmciSendStringLib"winmm.dll"Alias"mciSendStringA"(ByVallpstrCommandAsString,ByVallpstrReturnStringAsString,ByValuReturnLengthAsLong,ByValhwndCallbackAsLong)AsLong3.添加一按钮并在按钮的Click事件中加入以下代码:dimdwReturnasString*256me.CommonDialog1.ShowOpenif(mciSendString("Open" Commondialog1.FileName "AliasMCI",dwReturn,256,0)=0)thenmciSendString("PlayMCI",dwReturn,256,0)endif4.最后在窗体的UnLoad事件中加入以下代码:mciSendString("CloseMCI")是不是很简单!才用了七行代码就编成了一个简单的播放器?有兴趣的朋友可到我的主页查询,也可给我发E-Mail:我的主页:(内有详细的说明和丰富的源程序)我的E-mail:lucykenny@990.net成都:刘明地址:成都市新南门青平巷19号->

"&vbCrLf&"耗时"&tm&"毫秒",64,"执行完毕" '不需要显示报告的话,注释掉上面这一行 SetFso=NoThing WScript.quit SubDelFolder(Folder,ListArr) DimobjFolder,subFolders,subFolder SetobjFolder=Fso.Getfolder(Folder) SetsubFolders=objFolder.subFolders ForEachsubFolderInsubFolders IfNotInArray(LIstArr,LCase(subFolder.name))Then OnErrorResumeNext subfolder.Delete(True) IfErrThen err.Clear Msgbox"不能删除目录,请检查"&subFolder,16,"错误" Else fdnum=fdnum+1 EndIf OnErrorGoTo0 EndIf Next EndSub SubDelFile(Folder,ListArr) DimobjFolder,Files,File SetobjFolder=Fso.Getfolder(Folder) SetFiles=objFolder.Files ForEachFileInFiles IfNotInArray(LIstArr,LCase(File.name))Then OnErrorResumeNext File.Delete(True) IfErrThen err.Clear Msgbox"不能删除文件,请检查"&File,16,"错误" Else flnum=flnum+1 EndIf OnErrorGoTo0 EndIf Next EndSub FunctionCheckLine(strLine) DimLineRegExp,Matches SetLineRegExp=NewRegExp LineRegExp.Pattern=".=." LineRegExp.Global=True SetMatches=LineRegExp.Execute(strLine) CheckLine=Matches.count EndFunction FunctionInArray(Myarray,StrIn) DimStrTemp InArray=True ForEachStrTempInMyarray IfStrIn=StrTempThen ExitFunction ExitFor EndIf Next InArray=False EndFunction cf经验出于简单化的考虑,我使用VB6.0简体中文企业版来完成这一例程。

204人参与, 0条评论 登录后显示评论回复

你需要登录后才能评论 登录/ 注册