以下程序在2个位置(第39和45行)返回error : e2035 not enough actual parameters
并且未编译。有人可以帮帮我吗?
我可以在这里输入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.
答案 0 :(得分:5)
您可以在variants.pas;
上使用任何虚拟变量或“EmptyParam”变量MyBrowser.Navigate(loginURL,0,EmptyParam,EmptyParam,EmptyParam);
答案 1 :(得分:2)
Navigate的签名是
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);
答案 2 :(得分: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;