QQSERVER的USERLOGGING代码如下:
Dim pts() As String = e.UserName.Split(".")
Dim dr As DataRow
dr = DataTables("users").Find("dwmc = '" & pts(0) & "' And name = '" & pts(1) & "'")
If dr Is Nothing Then '判断此用户不存在
e.Message = "用户名错误!" '返回给登录者的提示信息
Return
End If
If dr("password") <> e.Password Then '如果密码错误
e.Message = "登录密码错误!" '返回给登录者的提示信息
Return
End If
e.Success = True '允许用户登录
'添加存储在好友列的非本部门的好友
If dr.IsNull("hy") = False Then
Dim nms() As String = dr("hy").Split(",")
e.Buddies.AddRange(nms)
End If
'最后添加相同部门的同事为好友
For Each dr In DataTables("users").Select("dwmc = '" & pts(0) & "'")
Dim nm As String = dr("dwmc") & "." & dr("name")
If nm <> e.UserName Then '如果不是登录者本人
e.Buddies.Add(nm)
End If
Next
QQclient 的登录代码 afterload事件代码e.Form.Controls("btnChat").Enabled = QQClient.Ready
登录按钮click代码
If QQClient.Ready Then
MessageBox.show("QQClient已经启动,请先关闭","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
Return
End If
QQClient.ServerIP = e.Form.Controls("txtIP").Value '指定服务器IP地址
QQClient.ServerPort = e.Form.Controls("txtPort").Value '指定服务器端口
QQClient.UserName = e.Form.Controls("txtUserName").Value '指定登录用户名
QQClient.Password = e.Form.Controls("txtPassword").Value
If QQClient.Start() = True '如果登录成功
e.Form.Controls("btnChat").Enabled = True
Dim msg As String = "恭喜,OpenQQ登录成功!"
If QQClient.ServerMessage > "" Then '如果服务器返回了欢迎信息
msg = msg & QQClient.ServerMessage
End If
popMessage(msg,"提示",PopiconEnum.Infomation,5)
Else '如果登录失败,显示服务器返回错误信息
e.Form.Controls("btnChat").Enabled = False
PopMessage("QQClient登录失败,原因:" & vbcrlf & QQClient.ServerMessage,"提示",PopiconEnum.Error,5)
End If