以下是我测试的结果:
李维书上调试例子(delphi6+windows 2000pro)
procedure TForm1.btnLoginClick(Sender: TObject);
var
// LoginObj : ImtsSecurityObj;
vCookie : OleVariant;
begin
if not assigned(LoginObj) then
LoginObj := ComtsSecurityObj.Create;
[red]//此处设置断点[/red]
// LoginObj := CreateComObject(CLASS_mtsSecurityObj) as ImtsSecurityObj;
LoginObj.Login(edtName.Text, edtPassword.Text, vCookie);
if (vCookie <> '') then
begin
edtCookie.Text := vCookie;
// edtCookie.Visible := True;
end
else
ShowMessage('無效的登錄');
end;
在com+组件设置的调试那[brown]不要[/brown]打钩
选PDemoProfileObject.dll,Run|Parameters
Host Application:C:/Program Files/MD53Demos/Ch06/DemoMTSObject/PClientDemo1.exe
Parameters:/ProcessID:{8DBEDFF5-7BC0-4BBC-8156-3212169EEF70}
按F9,输入姓名、密码,按登录按钮,可以trace into 到
class function ComtsSecurityObj.Create: ImtsSecurityObj;
begin
Result := CreateComObject(CLASS_mtsSecurityObj) as ImtsSecurityObj;
end;
但是,不能trace into 到
procedure TmtsSecurityObj.Login(const sName, sPassword: WideString;
var vCookie: OleVariant);
var
iCount : Integer;
aPerson : TSimpleProfile;
begin
vCookie := '';
for iCount := 0 to aProfile.Count - 1do
// Iterate
begin
aPerson := TSimpleProfile(aProfile.Items[iCount]);
if ( (aPerson.Name = sName) and (aPerson.Password = sPassword) ) then
vCookie := aPerson.Cookie;
end;
// for
end;