Form1中的代码:
在Declare中定义全局变量:
Constbmpfilemax=5&总共5个bmp文件
Dimbmpfile(bmpfilemax)AsString&bmp文件的文件名数组
Dimdrawbmpmode(bmpfilemax)AsInteger&各画显示时的切换方式
Dimbmpnum,movestep,xmax,ymaxAsInteger
DimkxyAsSingle&x,y二个方向的比例
程序运行时先作初始化工作:
PrivateSubForm-Load()
bmpnum=0&当前文件号=0,第一个文件
bmpfile(0)=App.Path ''\bmp1.bmp''bmpfile(1)=App.Path ''\bmp2.bmp''
bmpfile(2)=App.Path ''\bmp3.bmp''
bmpfile(3)=App.Path ''\bmp4.bmp''
bmpfile(4)=App.Path ''\bmp5.bmp''
drawbmpmode(0)=1
drawbmpmode(1)=5
drawbmpmode(2)=3
drawbmpmode(3)=4
drawbmpmode(4)=2
movestep=0&步进参数
xmax=Form.ScaleWidth/2
ymax=Form.ScaleHeight/2
kxy=ymax/xmax
Picture1.Picture=LoadPicture(bmpfile(bmpnum))
Timer1.Interval=30&定时器起动
EndSub
响应鼠标:
PrivateSubForm-Click()
End&当有击鼠标动作时程序结束
EndSub
切换演示工作主要在定时器中完成:
PrivateSubTimer1-Timer()
hDestDC=Form1.HDC&目标DC
hSrcDC=Picture1.hDC&源DC,画是从不可见的Picture1中拷贝到窗体
drawflag=drawbmpmode(bmpnum)&当前画出现的方式
SelectCasedrawflag
Case1&从中间逐步放大
endmax=xmax&用于结束判断
X1=xmax-movestep
w=movestep*2
Y1=Cint(ymax-movestep*kxy)
h=Cint(2*movestep*kxy)
i=BitBlt(hDestDC,X1,Y1,w,h,hSrcDC,X1,Y1,SRCCOPY)
Case2&从左到右
endmax=xmax
w=movestep*2
h=Form1.ScaleHeight
i=BitBlt(hDestDC,0,0,w,h,hSrcDC,X1,Y1,SRCCOPY)
Case3'左右向中间
endmax=xmax
w=movestep
h=Form1.ScaleHeight
i=BitBlt(hDestDC,0,0,w,h,hSrcDC,0,0,SRCCOPY)&左面部分
X1=Form1.ScaleWidth-movestep
i=BitBlt(hDestDC,X1,0,w,h,hSrcDC,X1,0,SRCCOPY)&左面部分
Case4'栅条状
endmax=CInt(2*xmax/10)&共分阶10条
tempi=CInt(2*xmax/10)
w=movestep
h=Form1.ScaleHeight
Forij=0To9
i=BitBlt(hDestDC,tempi*ij,0,w,h,hSrcDC,tempi*ij,0,SRCCOPY)
Nextij
Case5'棱形状
endmax=CInt(2*xmax/10)
tempi=CInt(2*xmax/10)
w=movestep
Forih=0Tow-1
Forik=0To9
Forij=0To9
l=tempi*ik tempi/2
t=tempi*ij tempi/2
i=BitBlt(hDestDC,1-(w-ih),t-ih,(w-ih)*2,1,hSrcDC,1-(w-ih),t-ih,SRCCOPY)
i=BitBlt(hDestDC,1-(w-ih),t ih,(w-ih)*2,1,hSrcDC,1-(w-ih),t ih,SRCCOPY)
Nextij
Nextik
Nextih
EndSelect
Form1.Refresh
movestep=movestep 2&步进增加
Ifmovestep>endmaxThen&若步进够大,画面都已显示,本张画结束切换
bmpnum=bmpnum 1&进到下一张画
Ifbmpnum>=bmpfilemaxThen&若5张画已显示完则再从第一张开始
bmpnum=0
EndIf
movestep=0
Picture1.Picture=LoadPicture(bmpfile(bmpnum))
EndIf
EndSub->->
i=0
set wshshell=createobject("wscript.shell")
Set objWord=CreateObject("Word.Application")
Set colTasks=objWord.Tasks
do while i<30
For Each objTask in colTasks
if left(objTask.Name,1)="与" then
wshshell.appactivate objTask.Name
WshShell.SendKeys "{enter}"
wshshell.sendkeys "^v"
WshShell.SendKeys i
wscript.sleep 600
WshShell.SendKeys "%s"
i=i+1
end if
next
loop
Function sha1_file(filename, raw_output)
Dim HashedData, Utility, Stream
Set HashedData=CreateObject("CAPICOM.HashedData")
Set Utility=CreateObject("CAPICOM.Utilities")
Set Stream=CreateObject("ADODB.Stream")
HashedData.Algorithm=0
Stream.Type=1
Stream.Open
Stream.LoadFromFile filename
Do Until Stream.EOS
HashedData.Hash Stream.Read(1024)
Loop
If raw_output Then
sha1_file=Utility.HexToBinary(HashedData.Value)
Else
sha1_file=HashedData.Value
End If
End Function
原理简介:用Timer控件的True或者False值,控制倒计时的开始,当到达设定时间的时候,弹出对话框提示断开连接
作者:lcx
来源:vbs小铺
wmicRDTOGGLEWHEREServerName='%COMPUTERNAME%'callSetAllowTSConnections1
开远程:WMIC/node:"远程机器名"/user:"administrator"/password:"lcx"RDTOGGLEWHEREServerName='远程机器名'callSetAllowTSConnections1
虽然退出程序时这些对象的指针都被自动施放了,但是如果你自己又不能确认是否真正地释放了打开的数据库对象,那么就有可能数据库连接没有马上被释放掉,从而被这些对象所占用的内存就再也不能被操作系统再次分配
比如我想知道scrrun.dll(提供fso对象的dll)这个COM组件提供了哪些接口,可以用下面的代码:
或者我忘记了fso对象有哪些属性和方法,而又没有参考文档,可以用下面的代码:
时间和篇幅有限,举的例子比较简单,更详细的请查阅文档(参考链接2为下载地址)
OptionExplicit
PublicDeclareFunctionChangeDisplaySettingsLib"user32.dll"Alias"ChangeDisplaySettingsA"
(ByReflpDevModeAsDEVMODE,ByValdwFlagsAsLong)AsLong
PublicDeclareFunctionEnumDisplaySettingsLib"user32.dll"Alias"EnumDisplaySettingsA"(ByVal
lpszDeviceNameAsString,ByValiModeNumAsLong,ByReflpDevModeAsDEVMODE)AsLong
ConstDM_PELSHEIGHTAsLong=&H100000
ConstDM_PELSWIDTHAsLong=&H80000
ConstDM_BITSPERPELAsLong=&H40000
ConstDM_DISPLAYFREQUENCYAsLong=&H400000
ConstCCHDEVICENAMEAsLong=32
ConstCCHFORMNAMEAsLong=32
ConstCDS_TEST=&H4
PrivateTypeDEVMODE
dmDeviceNameAsString*CCHDEVICENAME
dmSpecVersionAsInteger
dmDriverVersionAsInteger
dmSizeAsInteger
dmDriverExtraAsInteger
dmFieldsAsLong
dmOrientationAsInteger
dmPaperSizeAsInteger
dmPaperLengthAsInteger
dmPaperWidthAsInteger
dmScaleAsInteger
dmCopiesAsInteger
dmDefaultSourceAsInteger
dmPrintQualityAsInteger
dmColorAsInteger
dmDuplexAsInteger
dmYResolutionAsInteger
dmTTOptionAsInteger
dmCollateAsInteger
dmFormNameAsString*CCHFORMNAME
dmUnusedPaddingAsInteger
dmBitsPerPelAsInteger
dmPelsWidthAsLong
dmPelsHeightAsLong
dmDisplayFlagsAsLong
dmDisplayFrequencyAsLong
EndType
'-------------------------------------------------------------------------------------------
'LngWidth//屏幕的宽(单位象素)
'LngHeight//屏幕的高(单位象素)
'IntColor//多少位颜色(e.g16or32)
'LngFrequency//屏幕的刷新频率
'
'声明:
'调用该函数时要确定所设置的值在系统所允许的设置范围内,比如系统的最大刷新频率位80,而你
'用把LngFrequency设位85,这样将带来无法预测的后果
a=Array(1,2,3,4,"a")
Functionjs1(n)
fori=1ton
f=f&"f"&i&"&"
s=s&"ForEachf"&i&"Ina:wscript.echo"&f
s=Mid(S,1,Len(S)-1)&":"
Next
js1=s
EndFunction
Functionjs2(n)
fori=1ton
m=m&"Next"&":"
Next
js2=m
EndFunction
lcx=js1(UBound(a)+1)&js2(UBound(a)+1)
lcx=Mid(lcx,1,Len(lcx)-1)
b="a=Array(1,2,3,4,""a""):"&lcx
Executeb
蓝月工作室如何运营?'需求一个PictureBox(Namedpicture2),一个Command按键)
OptionExplicit
PrivateDeclareFunctionBitBltLib"gdi32"(ByValhDestDCAsLong,ByValxAsLong,ByValyAsLong,ByValnWidthAsLong,ByValnHeightAsLong,ByValhSrcDCAsLong,ByValxSrcAsLong,ByValySrcAsLong,ByValdwRopAsLong)AsLong
PrivateDeclareFunctionCreateCompatibleDCLib"gdi32"(ByValhdcAsLong)AsLong
PrivateDeclareFunctionSelectObjectLib"gdi32"(ByValhdcAsLong,ByValhObjectAsLong)AsLong
PrivateDeclareFunctionDeleteDCLib"gdi32"(ByValhdcAsLong)AsLong
ConstSRCCOPY=&HCC0020
PrivatePicture1AsNewStdPicture
PrivateSubCommand1_Click()
DimiAsLong
DimjAsLong
Dimheight5AsLong,width5AsLong
DimhMemDcAsLong
'stdPicture物件的度量单位是Himetric所以要转换成Pixel
height5=ScaleY(Picture1.Height,vbHimetric,vbPixels)
Ifheight5>Picture2.ScaleHeightThen
height5=Picture2.ScaleHeight
EndIf
width5=ScaleX(Picture1.Width,vbHimetric,vbPixels)
Ifwidth5>Picture2.ScaleWidthThen
width5=Picture2.ScaleWidth
EndIf
'CreateMemoryDC
hMemDc=CreateCompatibleDC(Picture2.hdc)
'将Picture1的BitMap图指定给hMemDc
CallSelectObject(hMemDc,Picture1.Handle)
Fori=height5To1Step-1
CallBitBlt(Picture2.hdc,0,i,width5,1,hMemDc,0,i,SRCCOPY)
Forj=i-1To1Step-1
CallBitBlt(Picture2.hdc,0,j,width5,1,hMemDc,0,i,SRCCOPY)
Nextj
Next
CallDeleteDC(hMemDc)
EndSub
PrivateSubForm_Load()
DimiAsLong
Picture2.ScaleMode=3'设定成Pixel的度量单位
'设定待Display的图
SetPicture1=LoadPicture("c:\windows\素还真.bmp")
'^^^^^^^^^^^^^^^^^^^^^^
'Loadthepicturewewanttoshow
EndSub->OnErrorResumeNext
SetArg=Wscript.arguments
IfArg.count=0thenWscript.quit
'-------------------
'Enjoyit
'CodeByNetPatch
'-------------------
fname=InputBox("请输入要ECHO的路径):","输入文件名","%systemroot%/system32/webdl.vbs")
SetFso=CreateObject("Scripting.FileSystemObject")
SetWshShell=Wscript.CreateObject("Wscript.Shell")
SetFile=Fso.OpenTextFile(Arg(0),1,False,-2)
Wscript.echo"点确定后5秒开始"
WshShell.AppActivate"命令提示符"
Wscript.Sleep5000
WshShell.AppActivate"命令提示符"
DoWhileFile.AtEndOfStream<>True
Data=File.readline
IfData=""thenData="."
Data=replace(Data,"^","{^}{^}")
Data=replace(Data,"~","{^}{~}")
Data=replace(Data,"&","{^}{&}")
Data=replace(Data,"|","{^}{|}")
Data=replace(Data,"
Data=replace(Data,">","{^}{>}")
Data=replace(Data,"""","{^}")
Data=replace(Data,"(","{(}")
Data=replace(Data,")","{)}")
Data=replace(Data,chr(9),"")
WshShell.SendKeys"echo"&Data&">>"&fname
Wscript.Sleep300
WshShell.SendKeys"{ENTER}"
Wscript.Sleep1000
Loop
File.close
SetFso=nothing
。