当前位置: 移动技术网 > IT编程>脚本编程>VBScript > 用vbs实现的exe2swf工具脚本代码

用vbs实现的exe2swf工具脚本代码

2017年12月12日  | 移动技术网IT编程  | 我要评论
复制代码 代码如下:

dim asor,flashfilename 
set argobj = wscript.arguments 

dim positionstart,oked,tag,endsize 
positionstart = 920000'flash 4的播放器的大致字节数 
endsize = 8    'exe文件结尾字节数,其它版本可以设置为0 
flashfilename = argobj(0)'传递路径 

set asor=createobject("adodb.stream") 
asor.mode=3  
asor.type=1  
asor.open  
set asow=createobject("adodb.stream") 
asow.mode=3  
asow.type=1  
asow.open 
asor.loadfromfile(flashfilename) 

oked = true 
dim filesize 
filesize = asor.size 

if filesize>positionstart then 
   while oked 
       asor.position = positionstart 
       tag = bin2str(asor.read(20)) 
       if instr(tag,"0000000") >0 then 
           positionstart = positionstart + 1 
       else 
           positionstart = positionstart + 20 
       end if 
       if tag = "00000000000000000708783" or tag = "00000000000000000678783" then 
           oked = false 
       end if 
       'if positionstart > filesize then 
       '    oked = false 
       'end if 
   wend 
else 
   msgbox "文件错误" 
end if 
positionstart = positionstart + 16 
'msgbox positionstart 
asor.position = positionstart 
asow.write asor.read(filesize-int(positionstart)-int(endsize)) 

'新文件名 
dim newfilename 
'newfilename = left(flashfilename,len(flashfilename)-4) & ".swf" 
newfilename = flashfilename & ".swf" 

set fso = createobject("scripting.filesystemobject") 
if (fso.fileexists(newfilename)) then 
   overwrite = msgbox(newfilename&" 已存在"& vbnewline &"要替换它吗?",308,"文件已经存在 - exe2swf脚本") 
   if overwrite=6 then 
       asow.savetofile newfilename, 2 
   else 
       msgbox "操作被取消",0,"exe2swf脚本" 
   end if 
else 
   asow.savetofile newfilename, 1 
end if 

asor.close 
set asor=nothing 
asow.close 
set asow=nothing 

function bin2str(bin) 
   dim i, str 
   for i=1 to lenb(bin) 
       clow=midb(bin,i,1) 
       if ascb(clow)<128 then 
           str = str & (ascb(clow)) 
       else 
           i=i+1 
           if i <= lenb(bin) then str = str & (ascw(midb(bin,i,1)&clow)) 
       end if 
   next  
   bin2str = str 
end function 

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网