0

以下程序error : e2035 not enough actual parameters在 2 个地方(第 39 行和第 45 行)返回并且未编译。有人可以帮我吗?我可以在这里用 0 或 null 代替参数吗?

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs,ComObj,shdocvw,activex, StdCtrls;

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

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
  var
   mybrowser : iwebbrowser2;
  myUserName,
myPassword,loginURL : string;
    Flags: OleVariant;

begin
    Flags :=  navOpenInNewWindow;
     MyBrowser := CreateOleObject('InternetExplorer.Application') as IWebBrowser2;
MyBrowser.Navigate('http://www.gmail.com',flags,'_blank');

myUserName := 'UserName';
myPassword := 'password';
loginURL:='javascript:var Email = document.getElementById(''Email'');Email.value=''' + myUserName + ''';var Password = document.getElementById(''Passwd'');Password.value=''' + myPassword + ''';var SignIn = document.getElementById(''signIn'');SignIn.click();';

MyBrowser.Navigate(loginURL);

end;

end.
4

3 回答 3

5

您可以在 variables.pas 上使用任何虚拟变量或“EmptyParam”变量;

MyBrowser.Navigate(loginURL,0,EmptyParam,EmptyParam,EmptyParam);
于 2010-05-23T12:32:40.270 回答
2

使用 TWebBrowser 或传入EmptyParam(Delphi 源代码)SHDocVw.pas

procedure TWebBrowser.Navigate(const URL: WideString);
begin
  DefaultInterface.Navigate(URL, EmptyParam, EmptyParam, EmptyParam, EmptyParam);
end;

procedure TWebBrowser.Navigate(const URL: WideString; const Flags: OleVariant);
begin
  DefaultInterface.Navigate(URL, Flags, EmptyParam, EmptyParam, EmptyParam);
end;

procedure TWebBrowser.Navigate(const URL: WideString; const Flags: OleVariant;
                               const TargetFrameName: OleVariant);
begin
  DefaultInterface.Navigate(URL, Flags, TargetFrameName, EmptyParam, EmptyParam);
end;

procedure TWebBrowser.Navigate(const URL: WideString; const Flags: OleVariant;
                               const TargetFrameName: OleVariant; var PostData: OleVariant);
begin
  DefaultInterface.Navigate(URL, Flags, TargetFrameName, PostData, EmptyParam);
end;

procedure TWebBrowser.Navigate(const URL: WideString; const Flags: OleVariant;
                               const TargetFrameName: OleVariant; var PostData: OleVariant;
                               const Headers: OleVariant);
begin
  DefaultInterface.Navigate(URL, Flags, TargetFrameName, PostData, Headers);
end;
于 2010-05-23T16:58:10.973 回答
2

导航的签名是

    procedure Navigate(const URL: WideString; const Flags: OleVariant;
                   const TargetFrameName: OleVariant; var PostData: OleVariant;
                   const Headers: OleVariant); safecall;

所以你确实需要更多参数。有关 MSDN 官方文档,请参阅MSDN

你可以写

var
  PostData: OleVariant;

PostData := 0;
MyBrowser.Navigate('http://www.gmail.com',flags,'_blank', PostData, 0);
于 2010-05-23T12:33:06.840 回答