|
7#
楼主 |
发表于 2014-6-18 09:31:12
|
只看该作者
delphi 版 Server端 :
- function VerifyUser_CallBack(lpUserName,lpPassword:LPCTSTR;lpUserID,
- lpUserLevel:LPDWORD;lpNickName:LPTSTR; dwNCLen:DWORD;lpUserValue:Pointer):DWORD;stdcall;
- var
- DBOpt: TDBOpt;
- strUserNC,strTemp: String;
- begin
- TfrmMain.InsertLog('用户[' + lpUserName + ']请求登陆,开始对其身份进行验证');
- DBOpt := TDBOpt.create(frmMain.ADOcon);
- try
- if DBOpt.VerifyUser(lpUserName,lpPassword,strUserNC) = False then
- begin
- TfrmMain.InsertLog('用户[' + lpUserName + ']身份验证失败' );
- Result := 205;
- Exit;
- end;
- finally
- DBOpt.Free;
- end;
- nLonginCount := nLonginCount + 1;
- lpUserID^ := nLonginCount;
- lpUserLevel^ := 0;
- ZeroMemory(@lpNickName,SizeOf(strUserNC));
- lpNickName := PChar('yyp');
- //dwNCLen := Length(strUserNC);
- TfrmMain.InsertLog('用户[' + lpUserName + ']身份验证成功 [ID: '
- + IntToStr(nLonginCount) + ' 用户: '+ lpUserName + ']');
- Result := 0;
- end;
复制代码 客户端代码:- procedure TfrmMain.OnGVClientLogin(var msg: TMessage);
- var
- logstr:String;
- dwUserID:longint;
- username: array[0..30]of Char;
- begin
- dwUserID :=longint(msg.WParam);
- if(msg.LParam= 0) then
- begin
- logstr:='登录服务器成功,自己的用户编号为;'+ inttostr(dwUserID);
- dwUserID := -1;
- ZeroMemory(@username,sizeof(username));
- BRAC_GetUserName(dwUserID,username,sizeof(username));
- BRAC_EnterRoom(1,0,0);
- m_VideoID := dwUserID;
- // 将用户的ID保存在第一个位置,否则在回调函数里面可能找不到绘制的位置
- //m_iUserID[0]:=dwUserID;
- end else begin
- logstr:=Format('登录服务器失败,出错代码为: %u ',[longint(msg.lParam)]);
- end;
- InsertLog(logstr);
- end;
复制代码 其中客户端调用getUserName(-1)仍然返回的是用户登录帐号
|
|