怎么才能知道netmessagesend函数的返回值是正确的

ajp2002 2003-08-22 10:01:06
我是菜鸟,
看msdn写的netmessagesend返回值是NERR_Success就成功可我不知道具体得值
而我看的返回值是123,怎么才能知道发送成功了阿。
...全文
77 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhouyong0371 2003-08-24
  • 打赏
  • 举报
回复
NET_API_STATUS nasRc; //return code from NetXxxx()

WCHAR msgname[20];
memset(msgname, 0, 20);
int len = GetDlgItemTextW(this->m_hWnd, IDC_RECEIVER, msgname, 20);
if (len == 0)
{
MessageBox("请输入接受者的电脑名称");
return;
}

//一次NetSend最多发出的字符串为895个字符。
WCHAR buf[1024];
memset(buf, sizeof(WCHAR), 1024);
len = GetDlgItemTextW(this->m_hWnd, IDC_MESSAGE, buf, 1024);
if (len == 0)
{
wcscpy(buf, L":)");
len =2;
}

nasRc=NetMessageBufferSend(NULL, //server name(null means this machine)
msgname, //name(alias) of recipient
NULL, //who this is from
(LPBYTE)buf, //, //message
len*sizeof(WCHAR));

switch(nasRc)
{
case ERROR_ACCESS_DENIED:
m_ctlResult.SetWindowText("ERROR: You do not have access to the requested function.");
break;
case ERROR_INVALID_PARAMETER:
m_ctlResult.SetWindowText("ERROR: One of the passed parameters is invalid.");
break;
case ERROR_NOT_SUPPORTED:
m_ctlResult.SetWindowText("ERROR: This network request is not supported.");
break;
case NERR_NameNotFound:
m_ctlResult.SetWindowText("ERROR: The user name could not be found or is not logged in.");
break;
case NERR_NetworkError:
m_ctlResult.SetWindowText("ERROR: A general failure occurred in the network hardware.");
break;
case NERR_Success:
m_ctlResult.SetWindowText("Message successfully sent!");
break;
default:
m_ctlResult.SetWindowText("ERROR: Unknown error");
break;
}
duqiang2050 2003-08-24
  • 打赏
  • 举报
回复
NET_API_STATUS NetMessageBufferSend(
LPWSTR servername,
LPWSTR msgname,
LPWSTR fromname,
LPBYTE buf,
DWORD buflen
);

Return Values:

ERROR_ACCESS_DENIED The user does not have access to the requested information.
ERROR_INVALID_PARAMETER The specified parameter is invalid.
ERROR_NOT_SUPPORTED This network request is not supported.
NERR_NameNotFound The user name could not be found.
NERR_NetworkError A general failure occurred in the network hardware.

18,356

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 网络编程
c++c语言开发语言 技术论坛(原bbs)
社区管理员
  • 网络编程
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧