C/C++ code#define _UNICODE
#define UNICODE
#include
#include
#include
#include
#include
#include
#include
#pragma comment(lib,"netapi32.lib")
int wmain(int argc, wchar_t *argv[])
{
int count;
wchar_t *wdest, *wfrom, *buffer,*wtarget;
DWORD dwReturn;
if((argc <4) || (argc >5))
{
printf("Usge: %S [Count]\n",argv[0]);
printf("Count: Count means number of times to send message,default is 1.\n");
return 0;
}
wdest = argv[1]; //目标计算机
wfrom = argv[2]; //源计算机
buffer = argv[3]; //发送的信息
count = _wtoi(argv[4]); //发送次数,缺省为1次
if(count ==0)
count = 1;
printf("count = %d\n",count);
dwReturn = NetMessageBufferSend(NULL, wdest, wfrom,
(LPBYTE)buffer, 2*lstrlen(buffer)); //因为buffer是Unicode编码,所以需要乘以2
if(dwReturn == NERR_Success)
{
printf("Send OK!");
while(count-->1)
{
NetMessageBufferSend(NULL, wtarget, wfrom, (LPBYTE)buffe,2*lstrlen(buffer));
}
return 0;
}
if(dwReturn == NERR_NameNotFound)
{
printf("The user name could not be found.\n");
return 0;
}
if(dwReturn == NERR_NetworkError)
{
printf("A general failure occurred in the network hardware.\n");
return 0;
}
if(dwReturn == ERROR_NOT_SUPPORTED)
{
printf("This network request is not supported.\n");
return 0;
}
if(dwReturn == ERROR_INVALID_PARAMETER)
{
printf("The specified parameter is invalid.\n");
return 0;
}
if(dwReturn == ERROR_ACCESS_DENIED)
{
printf("The user does not have access to the requested information.\n");
return 0;
}
else
printf("Unknown error!\n");
return 0;
}
------解决方案--------------------
星羽怎么什么代码都有啊