procedure TForm1.Button2Click(Sender: TObject);
var
d2,D:IHTMLDocument2;
d1:IHTMLDocument;
e:IHTMLElement;
e2:IHTMLElement2;
cp:IHTMLControlRange;
img,img1:IHTMLImgElement;
ce:IHTMLControlElement;
myitem:Olevariant;
i:integer;
begin D:= webbrowser1.Document as IHTMLDocument2;
e:=d.body as IHTMLElement;
e2:=e as IHTMLElement2;
cp:=e2.createControlRange as IHTMLControlRange;
d2:= webbrowser1.Document as IHTMLDocument2;
myitem := WebBrowser1.Document;
for i := 0 to D.images.length - 1 do
begin
img1:=D.all.item(i,varempty) as IHTMLImgElement;
if img1.src='images/buttom_01_01.jpg' then
img:=img1 AS IHTMLImgElement;
begin
end;
end;
// Clipboard.Assign(img as IHTMLImgElement);
// img:=d2.images.item('images/buttom_01_01.jpg',0) AS IHTMLImgElement;
ce:=img as IHTMLControlElement;
cp.add(ce);
cp.execCommand('Copy',false,0);
end;初始化如下
initialization
OleInitialize(nil);
finalization
OleUninitialize;//end.前面。
在uses中加入ActiveX
============================================不过运行时提示interface not supported ...不知道什么原因,,,急
var
d2,D:IHTMLDocument2;
d1:IHTMLDocument;
e:IHTMLElement;
e2:IHTMLElement2;
cp:IHTMLControlRange;
img,img1:IHTMLImgElement;
ce:IHTMLControlElement;
myitem:Olevariant;
i:integer;
begin D:= webbrowser1.Document as IHTMLDocument2;
e:=d.body as IHTMLElement;
e2:=e as IHTMLElement2;
cp:=e2.createControlRange as IHTMLControlRange;
d2:= webbrowser1.Document as IHTMLDocument2;
myitem := WebBrowser1.Document;
for i := 0 to D.images.length - 1 do
begin
img1:=D.all.item(i,varempty) as IHTMLImgElement;
if img1.src='images/buttom_01_01.jpg' then
img:=img1 AS IHTMLImgElement;
begin
end;
end;
// Clipboard.Assign(img as IHTMLImgElement);
// img:=d2.images.item('images/buttom_01_01.jpg',0) AS IHTMLImgElement;
ce:=img as IHTMLControlElement;
cp.add(ce);
cp.execCommand('Copy',false,0);
end;初始化如下
initialization
OleInitialize(nil);
finalization
OleUninitialize;//end.前面。
在uses中加入ActiveX
============================================不过运行时提示interface not supported ...不知道什么原因,,,急
解决方案 »
- 昨晚我射了六次,女朋友痛得都哭了。。。
- 走过路过的兄弟姐妹们都进来帮忙一下啊.......(十分火急,在线等)
- 怎么过滤数据啊,是布尔值的,麻烦大家帮帮忙了!过年散分!
- 简单问题,来就送了
- 简单问题一个,请大家解决?
- ADOTable 如何处理缓存更新(在线等待)
- 数据标的查询
- 一个关于StringGrid的问题
- 如何使得stringgrid控件中某一行或列显示*,如同edit控件中的passwordchar属性
- public Tables: List<TableSchem> 语句如何转化为delphi6语句。
- 为什么动网验证码与我用idhhp下载的不一致?????急,在线等!!!
- 从指定的网站下载指定的一个文件,并下载完后检测文件的完整性,并自动运行下载好的程序。这样要怎么实现呢?高手指教!
var
d2,D:IHTMLDocument2;
d1:IHTMLDocument;
e:IHTMLElement;
e2:IHTMLElement2;
cp:IHTMLControlRange;
img,img1:IHTMLImgElement;
ce:IHTMLControlElement;
myitem:Olevariant;
i:integer;
begin D:= webbrowser1.Document as IHTMLDocument2;
e:=d.body as IHTMLElement;
e2:=e as IHTMLElement2;
cp:=e2.createControlRange as IHTMLControlRange;
d2:= webbrowser1.Document as IHTMLDocument2;
myitem := WebBrowser1.Document;
for i := 0 to D.images.length - 1 do
begin
img1:=D.images.item(i,varempty) as IHTMLImgElement;
if img1.src='images/buttom_01_01.jpg' then
img:=img1 AS IHTMLImgElement;
end;
// Clipboard.Assign(img as IHTMLImgElement);
ce:=img as IHTMLControlElement;
try
cp.add(ce);
cp.execCommand('Copy',false,0);
except
end;
end;=============================
cp.add(ce);
运行到这里提示无效指针,,,
因为img 没name和id属性==========
最原始的代码是这样的
=============================
var
d2,D:IHTMLDocument2;
d1:IHTMLDocument;
e:IHTMLElement;
e2:IHTMLElement2;
cp:IHTMLControlRange;
img:IHTMLImgElement;
ce:IHTMLControlElement;
begin
D:= webbrowser1.Document as IHTMLDocument2;
e:=d.body as IHTMLElement;
e2:=e as IHTMLElement2;
cp:=e2.createControlRange as IHTMLControlRange;
d2:= webbrowser1.Document as IHTMLDocument2;
img:=d2.images.item('imgname',0) AS IHTMLImgElement;
ce:=img as IHTMLControlElement;
cp.add(ce);
cp.execCommand('Copy',false,0);
end;