1:我的.pas文件内容
unit pki;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, OleCtrls, SHDocVw,MSHTML;
type
TForm1 = class(TForm)
WebBrowser1: TWebBrowser;
private
{ Private declarations }
public
function getInputStr(WB: TWebBrowser; FieldName: String): String;
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
{ TForm1 }
function TForm1.getInputStr(WB: TWebBrowser; FieldName: String): String;
Var
Doc : IHTMLDocument2;
inputText : IHTMLInputTextElement;
begin
Doc := IHTMLDocument2(WB.Document);
if nil <> Doc then
begin
//如果T1不是IHTMLInputTextElement类型将出错
inputText := Doc.all.item(FieldName, 0) as IHTMLInputTextElement;
Result := inputText.value;
end;
end;
end.
2:编译后dll,pbl文件,并导入到tib3.0系统中,名空间为dyneinfo
在TIb系统中调用的代码是
unit MainForm;
interface
uses
Business.System,Business.Forms.Dialogs,Business.Forms, Business.Forms,dyneinfo;
type
TMainForm = class(TForm)
Button1: TButton;
WebBrowser1: TWebBrowser;
Button2: TButton;
Edit1: TEdit;
Edit2: TEdit;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure WebBrowser1DocumentComplete(Sender: TObject; const pDisp: IDispatch; var URL: object);
private
{private declarations}
public
{public declarations}
end;
implementation
procedure TMainForm.Button1Click(Sender: TObject);
begin
WebBrowser1.Navigate('D:\pki\IEpki\addCheckIdea.htm')
end;
procedure TMainForm.Button2Click(Sender: TObject);
Var
Doc : IHTMLDocument2;
inputText : IHTMLInputTextElement;
begin
Edit2.Text := dyneinfo.pki.getInputStr(WebBrowser1,'afds') ;
//此名话编译不通过
end;
end.
Edit2.Text := dyneinfo.pki.getInputStr(WebBrowser1,'afds') ;
//此名话编译不通过
提示错误为
[错误]Biz:\YWKJ1\CSPKI\YWGN1.FUNC.DIR\MainForm.Form.pas(37, 30): Undeclared identifier "getInputStr"
谢谢 |