Subject:
关于三层传递string的问题,急需帮助
[Print This Page]
Author:
guoqingaa
Time:
2008-3-15 13:38
Subject:
关于三层传递string的问题,急需帮助
[粤]GuoQingaa(65517285) 13:09:03
接口设计
附件图1
[粤]GuoQingaa(65517285) 13:09:29
procedure AddUser(const pUserName: WideString; const pMode: WideString;
const pHost: WideString; const pIP: WideString; const PConnTime: WideString); safecall;
[粤]GuoQingaa(65517285) 13:10:26
服务端
procedure TSaleMisdb.AddUser(const pUserName, pMode, pHost, pIP,
PConnTime: WideString);
var
_item : TListItem;
begin
with FrmSrvMain do
begin
try
lvUser.Items.BeginUpdate;
_item := lvUser.Items.Add;
_item.Caption := '';
_item.StateIndex := 4;
_item.SubItems.Add(pUserName);
_item.SubItems.Add(pMode);
_item.SubItems.Add(pHost);
_item.SubItems.Add(pIP);
_item.SubItems.Add(pConnTime);
//(FormatDateTime('yyyy-mm-dd hh:nn:ss zzz', now));
lvUser.Refresh;
finally
lvUser.Items.EndUpdate;
end;
LastLinkEdit.Text := pUserName;
end;
end;
[粤]GuoQingaa(65517285) 13:11:50
要达到的效果
附件图2
[粤]GuoQingaa(65517285) 13:12:27
进程状态
附件图3
[粤]GuoQingaa(65517285) 13:13:29
客户端关闭后,进程还在
附件图4
[粤]GuoQingaa(65517285) 13:15:15
客户端的部分代码
var
FUserName : WideString; //用户名称 '用户名'
FMode : WideString; //机器类型 '后台'
FHost : WideString; //计算机名 'HP2000'
FIP : WideString; //计算机IP '202.202.202.202'
FConntime : WideString; //登陆时间 '0000年00月00日 00:00:00 000'
[粤]GuoQingaa(65517285) 13:16:32
// 功能:将 String 转换成 WideString
function ChAnsiToWide(const StrA: AnsiString): WideString;
var
nLen: integer;
begin
Result := StrA;
if Result <> '' then
begin
nLen := MultiByteToWideChar(936, 1, PChar(@StrA[1]), -1, nil, 0);
SetLength(Result, nLen - 1);
if nLen > 1 then
MultiByteToWideChar(936, 1, PChar(@StrA[1]), -1, PWideChar(@Result[1]), nLen - 1);
end;
end;
[粤]GuoQingaa(65517285) 13:17:46
procedure TFrmCltLogin.ImgBtnOKClick(Sender: TObject);
var
vUserID, vPassword: string;
vUserName, vGroup: Variant;
vLogined: Variant;
begin
vUserID := edtID.Text; //获取编号
vPassword := edtPassword.Text; //获取密码
DM.SocketCn.AppServer.Logined(vUserID, vPassword, vUserName, vGroup, vLogined);
if not vLogined then
begin
Inc(i);
if i<3 then
begin
Show_MessageBox(2, PChar(Format(
'用户名和密码不正确,请检查后重新输入!您还有%s次机会?!'
,[IntToStr(3-i)])));
CltLogined := False;
Exit;
end
else
begin
Show_MessageBox(2, '您已尝试超过 3 次, 系统将停止运行!');
ImgBtnCancelClick(Sender);
end;
end
else
begin
//向全局记录变量赋值
// FAliasesName := edtAliasName.Text; //别名
FUserID := vUserID; //用户编号
FUserName := ChAnsiToWide(vUserName); //用户名称
FGroup := vGroup; //用户组
FHost := ChAnsiToWide(GetComputerName); //机器名
FIP := ChAnsiToWide(GetComputerIP); //机器IP地址
FMode := ChAnsiToWide('后台');
CltLogined := True;
Close;
end;
//设置主窗口菜单的有效性
// SetFuncs;
end;
[粤]GuoQingaa(65517285) 13:18:40
...
FConntime := ChAnsiToWide(FormatDateTime('yyyy-mm-dd hh:nn:ss zzz', now));
//登陆认证窗口
if not DspLoginCltExecute then
begin
//保存配置
SaveConfig;
Application.Terminate;
end
else
begin
DM.SocketCn.AppServer.AddUser(FUserName, FMode, GetComputerName,
GetComputerIP, FConntime);
end;
[粤]GuoQingaa(65517285) 13:19:20
主要相关代码就这个,为什么客户端关闭的时候进程还在
[粤]GuoQingaa(65517285) 13:19:26
怎么改
[粤]GuoQingaa(65517285) 13:20:05
//退出系统
procedure TFrmCltMain.FormCloseQuery(Sender: TObject;
var CanClose: Boolean);
begin
// if Application.MessageBox(PChar('确定要退出'+ Application.Title +'吗?'), '询问', MB_YESNO + MB_ICONQUESTION)=IDYES then
// begin
DM.SocketCn.AppServer.DelUser(FUserName, FMode, GetComputerName,
GetComputerIP, FConntime);
CanClose := True;
// end
// else
// CanClose := False;
end;
本人在此跪求帮助,期盼福音...
本人QQ 65517285 电子邮件: 13824372125@139.com
Image Attachment: [附件图1]
图1.jpg
(2008-3-15 13:38, 9.1 K) / Download count 431
http://bbs.cnpack.org/attachment.php?aid=388
Image Attachment: [附件图2]
图2.jpg
(2008-3-15 13:38, 9.12 K) / Download count 441
http://bbs.cnpack.org/attachment.php?aid=389
Image Attachment: [附件图3]
图3.jpg
(2008-3-15 13:38, 5.74 K) / Download count 425
http://bbs.cnpack.org/attachment.php?aid=390
Image Attachment: [附件图4]
图4.jpg
(2008-3-15 13:38, 5.99 K) / Download count 443
http://bbs.cnpack.org/attachment.php?aid=391
Welcome to CnPack Forum (http://bbs.cnpack.org/)
Powered by Discuz! 5.0.0