有一个WIN32 API 函数,名称好像是netbuffermessenger(),我做过的,但没有实现给所有组成员发送消息的功能
我做的,你可以参考: void CYaMessengerDlg::NetSendMsg(LPWSTR WksName,LPWSTR MSG) { CString str=GetCurtimeString(); result = NetMessageBufferSend(NULL,WksName, NULL, (LPBYTE)MSG, wcslen(MSG)*2 ); switch(result) { case ERROR_ACCESS_DENIED: m_ctrlErrorInfo.AddString(_TEXT("ERROR: You do not have access to the requested function."+str)); break;
case ERROR_INVALID_PARAMETER: m_ctrlErrorInfo.AddString(_TEXT("ERROR: One of the passed parameters is invalid."+str)); break;
case ERROR_NOT_SUPPORTED: m_ctrlErrorInfo.AddString(_TEXT("ERROR: This network request is not supported."+str)); break;
case NERR_NameNotFound: m_ctrlErrorInfo.AddString(_TEXT("ERROR: The user name could not be found or is not logged in.")+str); break;
case NERR_NetworkError: m_ctrlErrorInfo.AddString(_TEXT("ERROR: A general failure occurred in the network hardware.")+str); break;
case NERR_Success: m_ctrlErrorInfo.AddString(_TEXT("Message successfully sent!")+str); break;
void CYaMessengerDlg::NetSendMsg(LPWSTR WksName,LPWSTR MSG)
{
CString str=GetCurtimeString();
result = NetMessageBufferSend(NULL,WksName,
NULL,
(LPBYTE)MSG,
wcslen(MSG)*2
);
switch(result)
{
case ERROR_ACCESS_DENIED:
m_ctrlErrorInfo.AddString(_TEXT("ERROR: You do not have access to the requested function."+str));
break;
case ERROR_INVALID_PARAMETER:
m_ctrlErrorInfo.AddString(_TEXT("ERROR: One of the passed parameters is invalid."+str));
break;
case ERROR_NOT_SUPPORTED:
m_ctrlErrorInfo.AddString(_TEXT("ERROR: This network request is not supported."+str));
break;
case NERR_NameNotFound:
m_ctrlErrorInfo.AddString(_TEXT("ERROR: The user name could not be found or is not logged in.")+str);
break;
case NERR_NetworkError:
m_ctrlErrorInfo.AddString(_TEXT("ERROR: A general failure occurred in the network hardware.")+str);
break;
case NERR_Success:
m_ctrlErrorInfo.AddString(_TEXT("Message successfully sent!")+str);
break;
default:
m_ctrlErrorInfo.AddString(_TEXT("ERROR %d: Unknown error")+str);
}
}
///////////////////////////////////////////////////////////////////////////
void CYaMessengerDlg::OnMsgsend()
{
// TODO: Add your control notification handler code here
if(m_ctrlHostList.GetCurSel()==-1)
{
MessageBox("请选择用户机器名!","Error!",MB_OK);
return;
}
CString strHost,strText;
m_ctrlMsgEdit.GetWindowText(strText);
int nSel=m_ctrlHostList.GetCurSel();
m_ctrlHostList.GetText(nSel,strHost);
char c[100],b[100];
strcpy(c,strText);
strcpy(b,strHost);
WCHAR ws[256];
WCHAR wm[256];
MultiByteToWideChar( CP_ACP, 0, c,
strlen(c)+1, ws,
sizeof(ws)/sizeof(ws[0]) );
MultiByteToWideChar( CP_ACP, 0, b,
strlen(b)+1, wm,
sizeof(wm)/sizeof(wm[0]) );
NetSendMsg(wm,ws);
}