VB6 dll 自动编译工具

´---------------------------------------------------------------------------------------
´ 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 Shell = WScript.CreateObject("WSCript.shell")
    ´msgbox """" & sVBPath & "vb6"" /m """ & sVBP & """ /outdir """ & sOutpath & """"
    oShell.run """" & sVBPath & "vb6"" /m """ & sVBP & """ /outdir """ & sOutpath & """"
    Set Shell = Nothing
End Function

´//删除临时文件
Function DelTempFiles(sPath)
    Dim oShell
    Set Shell = 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 Shell = Nothing
End Function

´//得到扩展名
Function GetFileExtName(sFileName)
    Dim ipos, ilen
    ipos = InStr(sFileName, ".")
    ilen = Len(sFileName)
    GetFileExtName = Right(sFileName, ilen - ipos)
End Function

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/778857/viewspace-157090/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/778857/viewspace-157090/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值