取出验证码图片的代码,帮我转成delphi代码一下(50分)

  • 主题发起人 主题发起人 wlyft
  • 开始时间 开始时间
W

wlyft

Unregistered / Unconfirmed
GUEST, unregistred user!
public static Image GetRegCodePic(WebBrowser wbMail, string ImgName, string Src, string Alt)
{
HTMLDocument doc = (HTMLDocument)wbMail.Document.DomDocument;
HTMLBody body = (HTMLBody)doc.body;
IHTMLControlRange rang = (IHTMLControlRange)body.createControlRange();
IHTMLControlElement Img;
if (ImgName == "") //如果没有图片的名字,通过Src或Alt中的关键字来取
{
int ImgNum = GetPicIndex(wbMail, Src,Alt);
if (ImgNum == -1) return null;
Img = (IHTMLControlElement)wbMail.Document.Images[ImgNum].DomElement;
}
else
Img = (IHTMLControlElement)wbMail.Document.All[ImgName].DomElement;

rang.add(Img);
rang.execCommand("Copy", false, null);
Image RegImg = Clipboard.GetImage();
Clipboard.Clear();
return RegImg;
}

public static int GetPicIndex(WebBrowser wbMail, string Src, string Alt)
{
int imgnum = -1;
for (int i = 0; i < wbMail.Document.Images.Count; i++) //获取所有的Image元素
{
IHTMLImgElement img = (IHTMLImgElement)wbMail.Document.Images.DomElement;
if (Alt == "")
{
if (img.src.Contains(Src)) return i;
}
else
{
if (!string.IsNullOrEmpty(img.alt))
{
if (img.alt.Contains(Alt)) return i;
}
}
}
return imgnum;
}
 
img1.Picture.Bitmap := nil;
BitBlt(img1.Canvas.Handle, 0, 0, 48, 22, self.Canvas.Handle, 899, 522, SRCCOPY);//抓到IE大图
a1.Picture.Bitmap := nil;
a2.Picture.Bitmap := nil;
a3.Picture.Bitmap := nil;
a4.Picture.Bitmap := nil;

BitBlt(a1.Canvas.Handle, 0, 0, 12, 22, img1.Canvas.Handle, 0, 0, SRCCOPY);
BitBlt(a2.Canvas.Handle, 0, 0, 12, 22, img1.Canvas.Handle, 11, 0, SRCCOPY);
BitBlt(a3.Canvas.Handle, 0, 0, 12, 22, img1.Canvas.Handle, 22, 0, SRCCOPY);
BitBlt(a4.Canvas.Handle, 0, 0, 12, 22, img1.Canvas.Handle, 33, 0, SRCCOPY);
切割城4个小图,哈哈哈哈哈..........
玩什么高科技的山水。!
 
to http://www.ynxbs.com/
你要不就加一下我的QQ让我问你怎么样
3523956
 
后退
顶部