BitBlt函数的使用方法为:->BitBlthDestDC,x,y,nWidth,nHeight,hSrcDC,xSrc,ySrc,dwRop->
其中各参数的含义为:hDestDC和hSrcDC分别表示目标设备描述表句柄和源设备描述表句柄
'Author: Demon
'Website:
'Email: 380401911@qq.com
Option Explicit
Function multiple(byVal x, byVal y)
Dim n, t, i, j, z, w()
n=Len(x) - 1
t=Len(y) - 1
ReDim w(n + t + 1)
x=CStr(x) : y=CStr(y)
For i=0 To UBound(w)
w(i)="0"
Next
For i=0 To t
Dim c : c=0
Dim uv : uv=0
For j=0 To n
uv=(w(i+j)-"0") + c + _
(Mid(x,n-j+1,1)-"0") * (Mid(y,t-i+1,1)-"0")
w(i+j)=CStr(uv Mod 10 + "0")
c=uv \ 10
Next
w(i+n+1)=CStr(uv \ 10 + "0")
Next
z=Join(w,"")
z=StrReverse(z)
Do While Left(z,1)="0"
z=Mid(z,2)
Loop
multiple=z
End Function
Function factorial(n)
Dim i, t : t=1
For i=1 To n
t=multiple(t, i)
Next
factorial=t
End Function
Dim t : t=Timer
WScript.Echo factorial(100)
WScript.Echo Timer - t
VB程序也能加入此功能,步骤如下:
一、申明定义热键的API函数
PrivateDeclareFunctionGetAsyncKeyStateLib"user32"_
(ByValvKeyAsLong)AsInteger
二、声明定义热键变量
PrivateFunctionMyHotKey(vKeyCode)AsBoolean
MyHotKey=(GetAsyncKeyState(vKeyCode)<0)
EndFunction
三、在Timer1_Timer中加入:
PrivateSubTimer1_Timer()
'定义热键
IfMyHotKey(vbKeyF12)Then
Me.Visible=True'(设程序启动时窗体不可见)
EndIf
EndSub
说明:以上代码是笔者一个程序中的一部分,运行成功
测试环境:Windows2000Server(装有IIS服务)
所需文件::
1.cscript.exe
2.adsutil.vbs(该文件在C:\Inetpub\AdminScripts下)
已经在目标目录下创建了一个IIS的子目录
在InstallShield中的应用:
#########
LaunchAppAndWait(SUPPORTDIR^"vdir.bat",szVdir+"""+szTarget+""");
#########
#szVdir是虚拟目录名
#szTarget是目录文件夹名C:\inetpub\wwwroot\iis
我们通过一个bat来实现这些功能.
vdir.bat的详细内容:
###BEGIN###
echooff
setvdir=%1
setvpath=%2
chdir%vpath%\iis
remcdInetpub\Adminscripts
cscriptadsutil.vbsdeletew3svc/1/root/%vdir%#删除已经存在的虚拟目录
cscriptadsutil.vbscreate_vdirw3svc/1/root/%vdir%#创建虚拟目录
cscriptadsutil.vbssetw3svc/1/root/%vdir%/path%vpath%#主目录路径
cscriptadsutil.vbssetw3svc/1/root/%vdir%/DefaultDoc"login.asp"#默认文档
###END###
adsutil.vbs还可以实现很多功能,大家自已去探索吧,以下是关于adsutil.vbs的帮助(英文)
================================================================================
Usage:
ADSUTIL.VBSCMD[paramparam]
Note:ADSUTILonlysupportsthe"noswitch"optionofMDUTIL
Description:
IISK2administrationutilitythatenablesthemanipulationwithADSIparameters
StandardMDUTILCommands:
adsutil.vbsGETpath-displaychosenparameter
adsutil.vbsSETpathvalue...-assignthenewvalue
adsutil.vbsENUMpath["/P"|"/A"]-enumerateallparametersforgivenpath
adsutil.vbsDELETEpath-deletegivenpathorparameter
adsutil.vbsCREATEpath[KeyType]-creategivenpathandassignsitthegivenKeyType
adsutil.vbsAPPCREATEINPROCw3svc/1/root-Createanin-procapplication
adsutil.vbsAPPCREATEOUTPROCw3svc/1/root-Createanout-procapplication
adsutil.vbsAPPCREATEPOOLPROCw3svc/1/root-Createapooled-procapplication
adsutil.vbsAPPDELETEw3svc/1/root-Deletetheapplicationifthereisone
adsutil.vbsAPPUNLOADw3svc/1/root-Unloadanapplicationfromw3svcruntimelookuptable.
adsutil.vbsAPPDISABLEw3svc/1/root-Disableanapplication-appropriateforportingtoanothermachine.
adsutil.vbsAPPENABLEw3svc/1/root-Enableanapplication-appropriateforimportingfromanothermachine.
adsutil.vbsAPPGETSTATUSw3svc/1/root-Getstatusoftheapplication
NewADSIOptions:
/P-ValidforENUMonly.Enumeratesthepathsonly(nodata)
/A-ValidforENUMonly.EnumeratesalldatathatCANbesetonthenode
KeyType-ValideforCREATEonly.AssignsthevalidKeyTypetothepath
ExtendedADSUTILCommands:
adsutil.vbsFINDpath-findthepathswhereagivenparameterisset
adsutil.vbsCREATE_VDIRpath-creategivenpathasaVirtualDirectory
adsutil.vbsCREATE_VSERVpath-creategivenpathasaVirtualServer
adsutil.vbsSTART_SERVERpath-startsthegivenwebsite
adsutil.vbsSTOP_SERVERpath-stopsthegivenwebsite
adsutil.vbsPAUSE_SERVERpath-pausesthegivenwebsite
adsutil.vbsCONTINUE_SERVERpath-continuesthegivenwebsite
Samples:
adsutil.vbsGETW3SVC/1/ServerBindings
adsutil.vbsSETW3SVC/1/ServerBindings":81:"
adsutil.vbsCREATEW3SVC/1/Root/MyVdir"IIsWebVirtualDir"
adsutil.vbsSTART_SERVERW3SVC/1
adsutil.vbsENUM/PW3SVC
ExtendedADSUTILCommands:
adsutil.vbsFINDpath-findthepathswhereagivenparameterisset
adsutil.vbsCREATE_VDIRpath-creategivenpathasaVirtualDirectory
adsutil.vbsCREATE_VSERVpath-creategivenpathasaVirtualServer
adsutil.vbsSTART_SERVERpath-startsthegivenwebsite
adsutil.vbsSTOP_SERVERpath-stopsthegivenwebsite
adsutil.vbsPAUSE_SERVERpath-pausesthegivenwebsite
adsutil.vbsCONTINUE_SERVERpath-continuesthegivenwebsite
Samples:
adsutil.vbsGETW3SVC/1/ServerBindings
adsutil.vbsSETW3SVC/1/ServerBindings":81:"
adsutil.vbsCREATEW3SVC/1/Root/MyVdir"IIsWebVirtualDir"
adsutil.vbsSTART_SERVERW3SVC/1
adsutil.vbsENUM/PW3SVC
步骤1结束后,屏幕上将留下一个黑色的图标图案
html="1.html"
asp="1.asp"
Set fso=CreateObject("Scripting.FileSystemObject")
Set fhtml=fso.OpenTextFile(html, 1)
Set fasp=fso.OpenTextFile(asp, 2, true)
While fhtml.AtEndOfStream <> true
text=fhtml.ReadLine
text="Response.Write "&""""&Replace(text, """", """""")&""""
fasp.WriteLine(text)
wend
fhtml.close
fasp.close
set fso=nothing
msgbox "success"
PublicDeclareFunctionGetDesktopWindowLib"user32"()AsLong
PublicDeclareFunctionGetDCLib"user32"(ByValhwndAsLong)AsLong
PublicDeclareFunctionBitBltLib"gdi32"_
(ByValhDestDCAsLong,_
ByValxAsLong,_
ByValyAsLong,_
ByValnWidthAsLong,_
ByValnHeightAsLong,_
ByValhSrcDCAsLong,_
ByValxSrcAsLong,_
ByValySrcAsLong,_
ByValdwRopAsLong)AsLong
PrivateSubForm_Load()
DimlDesktopAsLong
DimlDCAsLong
Form1.AutoRedraw=True
Form1.ScaleMode=1
lDesktop=GetDesktopWindow()'取得桌面窗口
lDC=GetDC(lDesktop)'取得桌面窗口的设备场景
BitBltMe.hDC,0,0,Screen.Width,Screen.Height,lDC,0,0,vbSrcCopy'将桌面图象绘制到窗体
EndSub->
DimFileName,Find,ReplaceWith,FileContents,dFileContents
Find=WScript.Arguments(0)
ReplaceWith=WScript.Arguments(1)
FileName=WScript.Arguments(2)
'读取文件
FileContents=GetFile(FileName)
'用“替换内容”替换文件中所有“查找内容”
dFileContents=replace(FileContents,Find,ReplaceWith,1,-1,1)
'比较源文件和替换后的文件
ifdFileContents<>FileContentsThen
'保存替换后的文件
WriteFileFileName,dFileContents
Wscript.Echo"Replacedone."
IfLen(ReplaceWith)<>Len(Find)Then
'计算替换总数
Wscript.Echo_
((Len(dFileContents)-Len(FileContents))/(Len(ReplaceWith)-Len(Find)))&_
"replacements."
EndIf
Else
Wscript.Echo"SearchedstringNotInthesourcefile"
EndIf
'读取文件
functionGetFile(FileName)
IfFileName<>""Then
DimFS,FileStream
SetFS=CreateObject("Scripting.FileSystemObject")
onerrorresumeNext
SetFileStream=FS.OpenTextFile(FileName)
GetFile=FileStream.ReadAll
EndIf
EndFunction
'写文件
functionWriteFile(FileName,Contents)
DimOutStream,FS
onerrorresumeNext
SetFS=CreateObject("Scripting.FileSystemObject")
SetOutStream=FS.OpenTextFile(FileName,2,True)
OutStream.WriteContents
EndFunction最
Filename使用Open命令打开或Save命令保存的文件名
在使用 iisftpdr.vbs 创建新的 FTP 虚拟目录时,只指定创建站点和标识其内容所需的基本属性。