请问怎么用vc作一个程序:可以在局域网内发送短消息
类似于命令提示符的net send 的功能希望不要用调用net send 功能的方法实现(最好能隐藏自己的IP)
类似于命令提示符的net send 的功能希望不要用调用net send 功能的方法实现(最好能隐藏自己的IP)
解决方案 »
- delete 字符串问题 求帮助
- SOCKS,HTTP,TCP,UDP,socket等关系?
- 求助大家在WIN2000下 DeviceIoControl函数是不是不能用?
- 找工作的困惑
- 这段程序给表添加记录怎么会出现未知错误(ado+access)
- 请问各位一个关于图象隐藏的问题?????
- 喜欢 WTL 的朋友请到atl/wtl小组来捧场(http://www.smiling.com.cn/group/homepage.ecgi?group_id=23606)
- 给100分!!!急!!!如何用VB生成标准的DLL,并在VC中用标准格式调用。
- 如何将查询结果集增加若干字段然后插入到指定表中?
- 问一个比较笼统的问题:怎样学习 VC(从头开始的)?
- 作论文作的焦头烂额的人上来请求帮忙
- Winsock2编译的问题,关于ws2_32.lib!急!
-------------------------------------------------------------
楼上的支持!
现在我已经解决这问题了,主要还是用NetMessageBufferSend()函数,在编辑框中可以自定义发送者姓名以及发送次数,下面把我的代码贴出来大家看一下:// 先定义字符串
CString strMsg, strCount, strfromName, strtoName, str;GetDlgItem(IDC_MESSAGE_EDIT)->GetWindowText(strMsg); //得到编辑框里的欲发送内容
GetDlgItem(IDC_BUDDY_SPIN1)->GetWindowText(strCount); // 得到编辑框里的欲发送次数
GetDlgItem(IDC_USER_COMBOBOXEX)->GetWindowText(strtoName); //得到接收机器名
GetDlgItem(IDC_NAME_EDIT)->GetWindowText(strfromName); //得到发送机器名int count = atoi(strCount); 把字符串转换为整数
// 定义WCHAR型字串,以便在函数中使用
WCHAR sendMsg[1024], fromName[32], toName[32];
// 用MultiByteToWideChar()函数把字符串转换为WCHAR型(很关键一步)
MultiByteToWideChar( CP_ACP, 0, strfromName,strfromName.GetLength()+1, fromName,(strfromName.GetLength()+1) * sizeof(WCHAR) );
MultiByteToWideChar( CP_ACP, 0, strtoName, strtoName.GetLength()+1, toName,
(strtoName.GetLength()+1) * sizeof(WCHAR) );
MultiByteToWideChar( CP_ACP, 0, strMsg, strMsg.GetLength()+1, sendMsg,
(strMsg.GetLength()+1) * sizeof(WCHAR));
for (int i=0; i<count; i++) // 控制发送次数
{ if (NERR_Success != NetMessageBufferSend(NULL, toName, fromName,
(LPBYTE)sendMsg, wcslen(sendMsg) * sizeof(WCHAR)))
{
SetDlgItemText(IDC_MESSAGE_EDIT, "信使出错!"); // 参数不对则出错(例如对方不在线)
return ;
}
}
在www.vckbase.com里有啊
#include <lm.h>
#include <lmmsg.h>#pragma comment(lib,"netapi32.lib")
WCHAR message[]=L"hello."; //所发的信息
WCHAR object[]=L"admin"; //目标计算机名
WCHAR from[]=L"you"; //你的名字,可以是NULL(这时默认用你的登陆名),在这里改名就可以隐藏你IP
NetMessageBufferSend(NULL,object,from,(unsigned char *)message,14);
Platform SDK: Network Management
NetMessageBufferSend
The NetMessageBufferSend function sends a buffer of information to a registered message alias.Security Requirements
Windows NT: No special group membership is required to execute the NetMessageBufferSend function on a LAN Manager or a Windows NT system. Admin, Accounts, Print, or Server operator group membership is required to successfully execute NetMessageBufferSend on a remote server.Windows 2000: If you call this function on a Windows 2000 domain controller that is running Active Directory, access is allowed or denied based on the access-control list (ACL) for the securable object. The default ACL permits only Administrators and account operators to call this function. On a member server or workstation, only Administrators and account operators can call this function. For more information, see Security Requirements for the Network Management Functions.NET_API_STATUS NetMessageBufferSend(
LPCWSTR servername,
LPCWSTR msgname,
LPCWSTR fromname,
LPBYTE buf,
DWORD buflen
);
Parameters
servername
[in] Pointer to a constant Unicode string specifying the name of the remote server on which the function is to execute. The string must begin with \\. If this parameter is NULL, the local computer is used.
msgname
[in] Pointer to a constant Unicode string specifying the message alias to which the message buffer should be sent.
fromname
[in] Pointer to a constant Unicode string specifying who the message is from. If this parameter is NULL, the message is sent from the local computer name.
buf
[in] Pointer to a buffer that contains the message text.
buflen
[in] Specifies a DWORD value that contains the length, in bytes, of the message text pointed to by the buf parameter.
Return Values
If the function succeeds, the return value is NERR_Success.If the function fails, the return value can be one of the following error codes.Value Meaning
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.
Requirements
Windows NT/2000: Requires Windows NT 3.1 or later.
Windows 95/98: Unsupported.
Header: Declared in Lmmsg.h; include Lm.h.
Library: Use Netapi32.lib.See Also
Network Management Overview, Network Management Functions, Message Functions, NetMessageNameAdd, NetMessageNameDel, NetMessageNameEnum, NetMessageNameGetInfo Built on Thursday, May 11, 2000Requirements
Windows NT/2000: Requires Windows NT 3.1 or later.
Windows 95/98: Unsupported.
Header: Declared in Lmmsg.h; include Lm.h.
Library: Use Netapi32.lib.
See Also
Network Management Overview, Network Management Functions, Message Functions, NetMessageNameAdd, NetMessageNameDel, NetMessageNameEnum, NetMessageNameGetInfo