<%
Server.ScriptTimeOut=99999
Response.Buffer=true
dim trueurl,ContentType,start
   fname=Request.QueryString("f")
   start=Request.QueryString("start")

   select case lcase(right(fname,4))
      case ".flv"
      ContentType="appliation/octet-stream"
      case ".nnv"
      ContentType="appliation/octet-stream"
	  case else 
        Response.Write "文件不能下载:" & lcase(right(fname,4))
        Response.End
   end select
   
   
   
   trueurlurl=server.MapPath("./") & "\"&fname
   
   'Response.Write trueurlurl
   'Response.end
   
   set objStream=server.CreateObject("adodb.stream")
   objStream.Open 
   objStream.Type=1
   
   objStream.LoadFromFile trueurlurl&"i"
   if objStream.Size < start*4+13+4 then
		Response.Write "ErrorSize " & objStream.Size & "<=" & (start*4+13)
		Response.End
		objStream.Close
   end if
   dim shead,spos,sarray,headsize
   
   'head
   objStream.Position=13
   'pos
   sarray=objStream.Read(2)
   spos=AscW(sarray)
   if spos < 0 then
            spos = spos + 65536
   end if
   sarray=objStream.Read(2)
   headsize=AscW(sarray)
   if headsize < 0 then
            headsize = headsize + 65536
   end if
   headsize=headsize*65536+spos
   '--pos

   objStream.Position=start*4+13
   'pos
   sarray=objStream.Read(2)
   spos=AscW(sarray)
   if spos < 0 then
            spos = spos + 65536
   end if
   sarray=objStream.Read(2)
   start=AscW(sarray)
   if start < 0 then
            start = start + 65536
   end if
   start=start*65536+spos
   '--pos
   
   objStream.LoadFromFile trueurlurl
   
   shead=objStream.Read(headsize)

   
   if objStream.Size >start then 
    
	'Response.AddHeader "Content-Disposition", "attachment; filename="&fname google浏览器不认识。
	Response.AddHeader "Content-Length", objStream.Size-start+headsize
	Response.CharSet="UTF-8"
	Response.ContentType=ContentType
	objStream.Position=start
	Response.BinaryWrite shead
	
	dim toread
	toread=4096
	
	While Not objStream.EOS and Response.IsClientConnected()
	
	if objStream.Position+toread>objStream.Size then
		toread=objStream.Size-objStream.Position
	end if
	 Response.BinaryWrite objStream.Read(toread)
	 Response.Flush()
	Wend
   else
	Response.Write "No" 
   end if
   Response.Flush()
   Response.Clear()
   objStream.Close
   set objStream=nothing
%>