问题解决,还是得查MSDN
procedure TMainform.getyear;
var
ShellWindow: IShellWindows;
nCount: integer;
spDisp: IDispatch;
i,j,X,l: integer;
vi: OleVariant;
IE1: IWebBrowser2;
IDoc1: IHTMLDocument2;
iELC : IHTMLElementCollection ;
S,S2 : string;
HtmlSelEle : IHTMLSelectElement;
htmloption: IHTMLOptionElement;
op:Ihtmlelement;
begin
try
idoc1:=Web.Document as IHTMLDocument2;
ielc:=idoc1.Get_all;
j:=0;
while j<ielc.length-1 do
begin
Application.ProcessMessages;
spDisp := ielc.item(J, 0);
if SUCCEEDED(spDisp.QueryInterface(IHTMLselectelement ,HtmlSelEle))then
with HtmlSelEle do
begin
if name='nian' then
begin
for l:=0 to length-1 do
begin
remove(0);
j:=j+1;
end;
adq.Close;
adq.SQL.text:='select n from lw group by n';
adq.Open;
while not adq.Eof do
begin
op:=idoc1.createElement('OPTION');
op.setAttribute('aaa','bbb',0);
htmloption:=op as ihtmloptionelement;
htmloption.text:=adq.fieldbyname('n').asstring;
htmloption.value:='mynianchange/'+adq.fieldbyname('n').AsString;
add(op,htmlselele.length);
adq.Next;
j:=j-1;
end;
htmlselele.selectedIndex:=0;
end;
if name='qi' then
begin
for l:=0 to length-1 do
begin
remove(0);
j:=j+1;
end;
adq.Close;
adq.SQL.text:='select q from lw where n=(select min
from lw) group by q';
adq.Open;
while not adq.Eof do
begin
op:=idoc1.createElement('OPTION');
op.setAttribute('aaa','bbb',0);
htmloption:=op as ihtmloptionelement;
htmloption.text:=adq.fieldbyname('q').asstring;
htmloption.value:='myqichange/'+adq.fieldbyname('q').AsString;
add(op,htmlselele.length);
adq.Next;
j:=j-1;
end;
htmlselele.selectedIndex:=-1;
end;
end;
j:=j+1;
end;
except
end;
exit;
end;