发表于:2003-04-15 10:59:00
楼主
我在用Delphi5编程用DataServer作网络群发时,发送总返回错误,请帮忙查一查,谢谢。
程序如下:
//在CurrentSystem打开后得到DataServer句柄
hDataServer := CurrentSystem.DataServerHandle;
DsStartDataserver(hDataServer);
succ:=DsCreateMsgDataObject(hDataServer,DS_MSG_OUT_BROADCAST_DOMAIN,nil,nil,NO_Msg_code,@hBroadObj,nil,0);
//返回0正确
if succ=DS_OK then
begin
server:=UNACKD_RPT;
typename:=BINARY_FMT_STR;
succ2:=DsSetMsgDataOptions (hDataServer,hBroadObj,DS_DATA_OPTION_MESSAGE_SERVICE,@server);
//返回0正确
succ3:=DsSetMsgDataOptions (hDataServer,hBroadObj,DS_DATA_OPTION_TYPE_NAME,PChar(typename)); //返回0正确
succ4:=DsStartMsgDataObject (hDataServer, hBroadObj, True);
end;//返回0正确
GetMem(PBuf,1024);
//短消息头为2
PBuf[0]:=2;
str:=edtMsg.text;
len2:=length(str);
Pbuf[1]:=len2;
strpcopy(@PBuf[2],str);
succ5:=DsSetMsgDataObject(hDataServer,hBroadObj,len2+2,PBuf,DS_DATA_FMT_STRING);//此处返回9,表示Illegal object handle was passed in.