t = _wtoi(argv); //发送次数,缺省为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;
}
四、小结
本实例开发一个Windows信使服务
程序,以帮助读者深入了解Windows信使服务实现的内幕。