这是Delphi6的帮助中关于TCustomConnection.OnLogin事件的Example中的内容:This example shows how to use an OnLogin event handler to pass authentication information to the server. This example assumes that the connection component抯 LoginPrompt property isTrue and an AS_Login method has been added to the application server抯 interface (using the type library). AS_Login returns True if the user name and password are accepted, False otherwise.procedure Form1.MyDCOMConnectionLogin(Sender: TObject; UserName, Password: string); var EncryptedValues: OleVariant; begin { Create an encrypted version of the user name and password before sending them over an insecure connection. AS_Login decrypts them on the server side. } EncryptedValues := EncryptThem(UserName, Password); if not AppServer.AS_Login(EncryptedValues) then raise ELoginFailed.Create('Login rejected');end;Note that if the login fails, OnLogin raises an exception. The client application must catch this exception and provide feedback to the user:KeepTrying := True;while KeepTrying do begin try MyDCOMConnection.Connected := True; except on ELoginFailed do if MessageDlg('Incorrect password?retry?', mtError, [mbYes, mbNo], 0) <> mrYes then KeepTrying := False; end; end;
var
EncryptedValues: OleVariant;
begin
{ Create an encrypted version of the user name and password
before sending them over an insecure connection. AS_Login
decrypts them on the server side. }
EncryptedValues := EncryptThem(UserName, Password);
if not AppServer.AS_Login(EncryptedValues) then
raise ELoginFailed.Create('Login rejected');end;Note that if the login fails, OnLogin raises an exception. The client application must catch this exception and provide feedback to the user:KeepTrying := True;while KeepTrying do
begin
try
MyDCOMConnection.Connected := True;
except
on ELoginFailed do
if MessageDlg('Incorrect password?retry?', mtError, [mbYes, mbNo], 0) <> mrYes then
KeepTrying := False;
end;
end;
如果没搞错的话,TCustomConnection.OnLogin事件
应该是客户端连接服务器端时触发的事件,
我现在想要实现的是服务器端怎么得到
客户端的TCustomConnection.OnLogin事件所传入的参数,
也就是TCustomConnection.OnLogin事件中的
AppServer.AS_Login(EncryptedValues)方法的实现
(这个方法是在服务器端实现的),
谢谢plainsong(伤心的风★短歌) ,
但您提供的这个例子与我的想法恰恰相反。
我就可以用SocketConnection连接你的服务器端程序;如果服务器端的httpsrvr.dll
放在C:\Inetpub\scripts目录下,我又知道服务器的IP(这些都不是保密的),我就
可以用WebConnection连接服务器端程序。
当然,是不希望出现以上我想说的这种假设的,那请问怎么避免。 这就是我的问题。