如何在Delphi程序中实现Google搜索功能?(100分)

  • 主题发起人 主题发起人 刀剑如梦
  • 开始时间 开始时间

刀剑如梦

Unregistered / Unconfirmed
GUEST, unregistred user!
Google搜索HTML代码如下:
<!-- Search Google -->
<center>
<FORM method=GET action="http://www.google.com/search">
<TABLE bgcolor="#FFFFFF"><tr><td>
<A HREF="http://www.google.com/intl/zh-CN/">
<IMG SRC="http://www.google.com/logos/Logo_40wht.gif"
border="0" ALT="Google" align="absmiddle"></A>
<INPUT TYPE=text name=q size=31 maxlength=255 value="">
<INPUT TYPE=hidden name=hl value=zh-CN>
<INPUT type=submit name=btnG value="Google 搜索">
</td></tr></TABLE>
</FORM>
</center>
<!-- Search Google -->
 
这个问题嘛。。。关注。。记得看过过CSDN上的一篇文章介绍过。。。可惜忘了
 
你是指引用他的功能吗
何不用WebBrowser控件,然后直接输出上面的HTML代码呢
 
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, OleCtrls, SHDocVw,ActiveX;

type
TForm1 = class(TForm)
Button1: TButton;
WebBrowser1: TWebBrowser;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.DFM}
function ShowHtml(mWebBrowser: TWebBrowser; mStrings: TStrings): Boolean;
var
vMemoryStream: TMemoryStream;
begin
Result := False;
if not (Assigned(mStrings) and Assigned(mWebBrowser)) then Exit;
mWebBrowser.Navigate('about:blank');
if not Assigned(mWebBrowser.Document) then Exit;
vMemoryStream := TMemoryStream.Create;
try
mStrings.SaveToStream(vMemoryStream);
try
vMemoryStream.Position := 0;
Application.ProcessMessages; // :)
(mWebBrowser.Document as IPersistStreamInit).Load(
TStreamAdapter.Create(vMemoryStream));
except
Exit;
end;
finally
vMemoryStream.Free;
end;
Result := True;
end; { ShowHtml }

procedure TForm1.Button1Click(Sender: TObject);
begin
ShowHtml(WebBrowser1, Memo1.Lines);

end;

end.
 
想试一试效果
 
多人接受答案了。
 
后退
顶部