unit UnitLogin;
{$WARN SYMBOL_PLATFORM OFF}
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ComServ, ComObj, VCLCom, StdVcl, bdemts, DataBkr, DBClient,
MtsRdm, Mtx, ProjectLogin_TLB, Contnrs;
type
TSimpleProfile = class(TObject)
private
fName : string;
fPassword : string;
fCookie : string;
published
property Name : string read fName write fName;
property Password : string read fPassword write fPassword;
property Cookie : string read fCookie write fCookie;
end;
Tmtslogin = class(TMtsDataModule, Imtslogin)
private
{ Private declarations }
aProfile : TObjectList;
procedure SetupProfile;
protected
class procedure UpdateRegistry(Register: Boolean;
const ClassID, ProgID: string);
override;
procedure Login(const sName, sPassword: WideString;
var vCookie: OleVariant);
safecall;
public
{ Public declarations }
procedure Initialize;
destructor Destroy;
override;
end;
var
mtslogin: Tmtslogin;
implementation
{$R *.DFM}
class procedure Tmtslogin.UpdateRegistry(Register: Boolean;
const ClassID, ProgID: string);
begin
if Register then
begin
inherited UpdateRegistry(Register, ClassID, ProgID);
EnableSocketTransport(ClassID);
EnableWebTransport(ClassID);
end else
begin
DisableSocketTransport(ClassID);
DisableWebTransport(ClassID);
inherited UpdateRegistry(Register, ClassID, ProgID);
end;
end;
procedure TmtsLogin.Initialize;
begin
inherited;
aProfile := TObjectList.Create;
SetupProfile;
end;
Destructor TmtsLogin.Destroy;
begin
inherited;
aProfile.Clear;
aProfile.Free;
end;
procedure TmtsLogin.SetupProfile;
var
aPerson : TSimpleProfile;
begin
aPerson := TSimpleProfile.Create;
aPerson.Name := 'db';
aPerson.Password := 'db';
aPerson.Cookie := CreateClassID;
aProfile.Add(aPerson);
end;
procedure Tmtslogin.Login(const sName, sPassword: WideString;
var vCookie: OleVariant);//这里是Login方法!!!
var
iCount : Integer;
aPerson : TSimpleProfile;
begin
vCookie := '';
for iCount := 0 to aProfile.Count-1do
begin
aPerson := TSimpleProfile(aProfile.Items[iCount]);
if ( (aPerson.Name = sName) and (aPerson.Password = sPassword) ) then
vCookie := aPerson.Cookie;
end;
end;
initialization
TComponentFactory.Create(ComServer, Tmtslogin,
Class_mtslogin, ciMultiInstance, tmApartment);
end.