工具> DecodeFileFormatTxt.hta (通用模板)

<html>
<head>
<title>selfdec</title>
<meta http-equiv="Content-Type" content="text/html; charset=GB2312">
<HTA:APPLICATION 
	ID="selfdec" 
	APPLICATIONNAME="self" 
	VERSION="0.1" 
	SCROLL="no" 
	INNERBORDER="no" 
	CONTEXTMENU="no" 
	CAPTION="no" 
	ICON="no" 
	SHOWINTASKBAR="no" 
	SINGLEINSTANCE="yes" 
	SYSMENU="no" 
	MAXIMIZEBUTTON ="no"
	WINDOWSTATE="normal"
	NAVIGABLE="yes"
	/>

<SCRIPT LANGUAGE="VBScript">

'//保存文件
function saveFile(filename,str)

	set adodbStream = CreateObject("ADODB" & "." & "Stream")

	adodbStream.Type= 1
	adodbStream.Open
	adodbStream.write str
	adodbStream.SaveToFile filename,2
	adodbStream.Close

end function

'//VB数组转变成二进制格式
Function MultiByteToBinary(MultiByte)

	Dim RS, LMultiByte, Binary
	Const adLongVarBinary = 205
	Set RS = CreateObject("ADODB.Recordset")
	LMultiByte = LenB(MultiByte)
	If LMultiByte>0 Then
		RS.Fields.Append "mBinary", adLongVarBinary, LMultiByte
		RS.Open
		RS.AddNew
		RS("mBinary").AppendChunk MultiByte & ChrB(0)
		RS.Update
		Binary = RS("mBinary").GetChunk(LMultiByte)
	End If
	MultiByteToBinary = Binary

End Function

function DeleteMe()
	
	dim filename
	filename	= document.location.href

	filename	= mid(filename,instrrev(filename,"/")+1)

	Dim fso, MyFile
	Set fso		= CreateObject("Scripting.FileSystemObject")	
	Set MyFile	= fso.GetFile(filename)
		MyFile.Delete

end function

function exec()
	
	'//屏蔽错误
	'on error resume next

	'//改变窗体大小
	window.resizeTo 0,0

	dim data,t,kk,filename

	'//得到数据
	data		= document.getElementById("divData").innerText
	'//得到文件名
	filename	= document.getElementById("divFileName").innerText

	'//得到数据长度
 	u = len(data)
	
	'//获得文件数组
	for i=1 to u step 2
		t = mid(data,i,2)
		kk = kk & ChrB(clng("&H" & t))
	next

	'//转变成二进制格式
	dataArry = MultiByteToBinary(kk)
	
	'//保存文件	
	saveFile filename,dataArry

	'//删除自己
	DeleteMe

	'//关闭自己
	window.opener = nothing
	window.close

end function

</SCRIPT>
</head>
<body marginleft=0 marginright=0 onload="exec()">
<div id="divFileName"	style="display:none;"><!-- 填入生成文件名 --></div>
<div id="divData"		style="display:none;"><!-- 填入文件内容编码 --></div>
</body>
</html>

 

你可能感兴趣的:(html,VBScript,vb)