自动将文件中vbp提取,编译为dll,将如下存为.vbs 即可
'---------------------------------------------------------------------------------------
' module : vb compiler
' datetime : 03-5-30 15:45
' author : hardy he
' purpose : vb6 dll 自动编译工具
'---------------------------------------------------------------------------------------
' svbpath : vb6 运行目录, soutpath: 输出dll 目录, ssourcepath: vb源文件目录(包括子文件夹)
dim svbpath, soutpath, ssourcepath
svbpath = "d:\program files\microsoft visual studio\vb98\"
soutpath = "e:\719\com\"
ssourcepath = "e:\719\"
call searchvbp(ssourcepath)
call deltempfiles (soutpath)
'//遍历目录得到vbp 工程文件并编译
function searchvbp(spath)
dim fso, f, f1, fc, s, ff, ff1
set fso = createobject("scripting.filesystemobject")
set f = fso.getfolder(spath)
set fc = f.files
for each f1 in fc
if lcase(getfileextname(f1.name)) = "vbp" then
makedll (f1.path)
end if
next
set ff = f.subfolders
for each ff1 in ff
searchvbp (ff1.path)
next
end function
'// 编译
function makedll(svbp)
dim oshell
set oshell = wscript.createobject("wscript.shell")
'msgbox """" & svbpath & "vb6"" /m """ & svbp & """ /outdir """ & soutpath & """"
oshell.run """" & svbpath & "vb6"" /m """ & svbp & """ /outdir """ & soutpath & """"
set oshell = nothing
end function
'//删除临时文件
function deltempfiles(spath)
dim oshell
set oshell = wscript.createobject("wscript.shell")
'msgbox "del /q/f " & soutpath & "*.lib"
oshell.run "cmd /c del /q/f " & spath & "*.lib"
oshell.run " cmd /c del /q/f " & spath & "*.obj"
oshell.run " cmd /c del /q/f " & spath & "*.exp"
oshell.run " cmd /c del /q/f " & spath & "*.asp"
set oshell = nothing
end function
'//得到扩展名
function getfileextname(sfilename)
dim ipos, ilen
ipos = instr(sfilename, ".")
ilen = len(sfilename)
getfileextname = right(sfilename, ilen - ipos)
end function