<% ychar="0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z" '将数字和大写字母组成一个字符串 yc=split(ychar,",") '将字符串生成数组 ycodenum=4 for i=1 to ycodenum Randomize ycode=ycode&yc(Int((35*Rnd))) '数组一般从0开始读取,所以这里为35*Rnd next Response.Clear Response.ContentType="image/gif" set obj=Server.CreateObject("shotgraph.image") x=48 '图片的宽 y=22 '图片的高 obj.CreateImage x,y,8 '8是图片的颜色8位 obj.SetColor 0,255,255,255 obj.SetColor 1,0,0,0 obj.CreatePen "PS_SOLID",1,0 obj.SetBgColor 0 obj.Rectangle 0,0,x-1,y-1 obj.SetBkMode "TRANSPARENT" obj.CreateFont "Arial",136,18,1,False,False,False,False obj.SetTextColor 1 obj.TextOut 5,4,ycode&" " img=obj.GifImage(-1,1,"") Response.BinaryWrite (img) session("LinkRandCode") = ycode %>