W
winge
Unregistered / Unconfirmed
GUEST, unregistred user!
在用Delphi对Lotus Sametime进行COM编程中,代码如下:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls,ComObj, OleServer, STComTkLib_TLB;
type
TForm1 = class(TForm)
Button1: TButton;
STCommunityService: TCommunityService;
STLookupService: TLookupService;
STResolver: TResolver;
STIm: TIm;
STIMService: TInstantMessagingService;
STUser: TSTUser;
procedure Button1Click(Sender: TObject);
procedure STCommunityServiceLoggedIn(Sender: TObject;
var ev: OleVariant);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure STResolverResolved(Sender: TObject; var ev: OleVariant);
procedure STResolverResolveFailed(Sender: TObject; var ev: OleVariant);
private
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
begin
STCommunityService.LoginByPassword('SametimeServer','User','password');
end;
procedure TForm1.STCommunityServiceLoggedIn(Sender: TObject;
var ev: OleVariant);
begin
ShowMessage('Login OK');
STResolver.ConnectTo(STLookupService.CreateResolver(-1,-1));
STResolver.Resolve('user2');
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action := caFree;
end;
procedure TForm1.STResolverResolved(Sender: TObject; var [red]ev: OleVariant[/red]);
var
iST : IResolveEvent;
evdd: OleVariant;
isu : ISTuser;
begin
ShowMessage('Resolved OK');
[red]STIMService.CreateIm(ev.GetResolvedUser,IST_ENC_LEVEL_NONE,1);[/red]
end;
procedure TForm1.STResolverResolveFailed(Sender: TObject;
var ev: OleVariant);
begin
ShowMessage('Resolved Failed');
end;
end.
在STResolver的Resolved事件中的参数ev为OleVariant类型变量,根据类型库声明:
procedure TResolver.InvokeEvent(DispID: TDispID; var Params: TVariantArray);
begin
case DispID of
-1: Exit; // DISPID_UNKNOWN
1: if Assigned(FOnResolved) then
FOnResolved(Self, Params[0] {const IResolveEvent});
2: if Assigned(FOnResolveConflict) then
FOnResolveConflict(Self, Params[0] {const IResolveEvent});
3: if Assigned(FOnResolveFailed) then
FOnResolveFailed(Self, Params[0] {const IResolveEvent});
end; {case DispID}
end;
可看出ev为IResolveEvent,其GetResolvedUser的函数作为CreateIm的参数输入,CreateIm类型库声明如下:
function TInstantMessagingService.CreateIm(const STUserObject: ISTUser; EncLevel: Integer;
ImType: Integer): IIm;
在编译过程中始终无法通过,其在VB中的实现如下:
Private Sub MyResolver_Resolved(ByVal ev As STComTkLib.IResolveEvent)
TInstantMessagingService.CreateIm ev.GetResolvedUser
UserName.SetFocus
End Sub
请教各位高手在Delphi中如何解决?谢谢!
如需涉及编程的软件环境,可于我联系。
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls,ComObj, OleServer, STComTkLib_TLB;
type
TForm1 = class(TForm)
Button1: TButton;
STCommunityService: TCommunityService;
STLookupService: TLookupService;
STResolver: TResolver;
STIm: TIm;
STIMService: TInstantMessagingService;
STUser: TSTUser;
procedure Button1Click(Sender: TObject);
procedure STCommunityServiceLoggedIn(Sender: TObject;
var ev: OleVariant);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure STResolverResolved(Sender: TObject; var ev: OleVariant);
procedure STResolverResolveFailed(Sender: TObject; var ev: OleVariant);
private
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
begin
STCommunityService.LoginByPassword('SametimeServer','User','password');
end;
procedure TForm1.STCommunityServiceLoggedIn(Sender: TObject;
var ev: OleVariant);
begin
ShowMessage('Login OK');
STResolver.ConnectTo(STLookupService.CreateResolver(-1,-1));
STResolver.Resolve('user2');
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action := caFree;
end;
procedure TForm1.STResolverResolved(Sender: TObject; var [red]ev: OleVariant[/red]);
var
iST : IResolveEvent;
evdd: OleVariant;
isu : ISTuser;
begin
ShowMessage('Resolved OK');
[red]STIMService.CreateIm(ev.GetResolvedUser,IST_ENC_LEVEL_NONE,1);[/red]
end;
procedure TForm1.STResolverResolveFailed(Sender: TObject;
var ev: OleVariant);
begin
ShowMessage('Resolved Failed');
end;
end.
在STResolver的Resolved事件中的参数ev为OleVariant类型变量,根据类型库声明:
procedure TResolver.InvokeEvent(DispID: TDispID; var Params: TVariantArray);
begin
case DispID of
-1: Exit; // DISPID_UNKNOWN
1: if Assigned(FOnResolved) then
FOnResolved(Self, Params[0] {const IResolveEvent});
2: if Assigned(FOnResolveConflict) then
FOnResolveConflict(Self, Params[0] {const IResolveEvent});
3: if Assigned(FOnResolveFailed) then
FOnResolveFailed(Self, Params[0] {const IResolveEvent});
end; {case DispID}
end;
可看出ev为IResolveEvent,其GetResolvedUser的函数作为CreateIm的参数输入,CreateIm类型库声明如下:
function TInstantMessagingService.CreateIm(const STUserObject: ISTUser; EncLevel: Integer;
ImType: Integer): IIm;
在编译过程中始终无法通过,其在VB中的实现如下:
Private Sub MyResolver_Resolved(ByVal ev As STComTkLib.IResolveEvent)
TInstantMessagingService.CreateIm ev.GetResolvedUser
UserName.SetFocus
End Sub
请教各位高手在Delphi中如何解决?谢谢!
如需涉及编程的软件环境,可于我联系。