L
lijianfeng
Unregistered / Unconfirmed
GUEST, unregistred user!
各位,谁知道怎样用Delphi同SAP做接口,请看如下代码为登录SAP代码,但是怎样有SAPLogonCtrl_TLB这个控件
unit s_logon;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, OleCtrls, SAPLogonCtrl_TLB, StdCtrls,Grids ;
type
TForm1 = class(TForm)
SAPLogonControl1: TSAPLogonControl;
Panel1: TPanel;
StaticText1: TStaticText;
Button1: TButton;
procedure SAPLogonControl1Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
Connection :variant;
implementation
{$R *.DFM}
procedure TForm1.SAPLogonControl1Click(Sender: TObject);
begin
(* define connection *)
Connection:= SAPLogOnControl1.NewConnection;
(* start LogOn *)
if Connection.LogOn(0,false) = true then
begin
showmessage('Logon O.K.');
Button1.Enabled:= true;
end
else
begin
ShowMessage('Error on Logon :-(((');
SAPLogonControl1.Enabled:=true;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
(* cut connection *)
Connection.LogOff;
ShowMessage('System LogOff...');
SAPLogonControl1.Enabled:=true;
Button1.enabled :=false;
end;
end.
unit s_logon;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, OleCtrls, SAPLogonCtrl_TLB, StdCtrls,Grids ;
type
TForm1 = class(TForm)
SAPLogonControl1: TSAPLogonControl;
Panel1: TPanel;
StaticText1: TStaticText;
Button1: TButton;
procedure SAPLogonControl1Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
Connection :variant;
implementation
{$R *.DFM}
procedure TForm1.SAPLogonControl1Click(Sender: TObject);
begin
(* define connection *)
Connection:= SAPLogOnControl1.NewConnection;
(* start LogOn *)
if Connection.LogOn(0,false) = true then
begin
showmessage('Logon O.K.');
Button1.Enabled:= true;
end
else
begin
ShowMessage('Error on Logon :-(((');
SAPLogonControl1.Enabled:=true;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
(* cut connection *)
Connection.LogOff;
ShowMessage('System LogOff...');
SAPLogonControl1.Enabled:=true;
Button1.enabled :=false;
end;
end.