请看以下代码,有什么问题吗?(20分)

  • 主题发起人 主题发起人 dboat
  • 开始时间 开始时间
D

dboat

Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TForm1.PutDataframe(iName,ss,sBtnName:String);
var
ShellWindow: IShellWindows;
nCount: integer;
spDisp: IDispatch;
i,j,k: integer;
vi,l,o: OleVariant;
IE1: IWebBrowser2;
IDoc1: IHTMLDocument2;
oneframe:Ihtmlwindow2;
S1,S2 : string;
HtmlInputEle : IHTMLInputElement;
begin
ShellWindow := CoShellWindows.Create;
nCount := ShellWindow.Count;
for i := 0 to nCount - 1 do
begin
vi := i;
spDisp := ShellWindow.Item(vi);
if spDisp = nil then continue;
spDisp.QueryInterface( iWebBrowser2, IE1 );
if IE1 <> nil then
begin
IE1.Document.QueryInterface(IHTMLDocument2,iDoc1);
if iDoc1 <> nil then
begin
if idoc1.frames.length<>0 then
for k:= 0 to idoc1.frames.length-1 do
begin
l:=k;
spDisp:=idoc1.frames.item(l);
if SUCCEEDED(spDisp.QueryInterface(IHTMLWindow2 ,oneframe))then
begin
for j:=0 to oneframe.document.all.length-1 do
begin
Application.ProcessMessages;
spDisp := oneframe.document.all.item(J, 0);
if SUCCEEDED(spDisp.QueryInterface(IHTMLInputElement ,HtmlInputEle))then
with HtmlInputEle do
begin
S1:=Name;
S2:=Type_;
S2:=UpperCase(S2);
S1:=UpperCase(S1);
if (StrComp(PChar(S2),'TEXT')=0) or (StrComp(PChar(S2),'PASSWORD')=0) then
begin
if S1=UpperCase(iName) then
begin
value :=ss;
o:=oneframe.document.all.item(sBtnName,0);
o.click;
exit;
end;
end;
end;
end;
end;

end;
end;
end;
end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
putdataFrame('user_id','kmh','submit');
end;
功能为设置ie浏览器中input name=user_id的值为kmh
可是怎么没用呢?
if SUCCEEDED(spDisp.QueryInterface(IHTMLInputElement ,HtmlInputEle)) then
这句的值总是false
why?
 
来人啊,救命啊............
 
后退
顶部