如何调用NetMessageBufferSend发送音讯?
问题描述:
如何调用WINNT/2K/XP下的API函数NetMessageBufferSend模仿net send命令来发送音讯?
处理方案:
下面代码已测试成功,直接导入PBL即可
$PBExportHeader$w_main.srw
forward
global type w_main from Window
end type
type mle_1 from multilineedit within w_main
end type
type cb_1 from commandbutton within w_main
end type
type sle_1 from singlelineedit within w_main
end type
type st_2 from statictext within w_main
end type
type st_1 from statictext within w_main
end type
end forward
type icmp_echo_reply from structure
unsignedlong address
unsignedlong status
unsignedlong roundtriptime
unsignedlong datasize
unsignedlong reserved[3]
character data[250]
end type
global type w_main from Window
int X=1056
int Y=484
int Width=1531
int Height=1152
boolean TitleBar=true
string Title="NETMESSAGESEND"
long BackColor=80269524
boolean ControlMenu=true
boolean MinBox=true
boolean Resizable=true
mle_1 mle_1
cb_1 cb_1
sle_1 sle_1
st_2 st_2
st_1 st_1
end type
global w_main w_main
type prototypes
Function ulong NetMessageBufferSend(ulong servername, ref char msgname[],ulong fromname, ref char buf[], ulong buflen) Library "netapi32.dll" Alias for "NetMessageBufferSend"
Function ulong IcmpCreateFile () Library "icmp.dll"
Function long IcmpSendEcho (ulong IcmpHandle, ulong DestinationAddress, string RequestData,long RequestSize, long RequestOptions, Ref icmp_echo_reply ReplyBuffer, long ReplySize, long Timeout ) Library "icmp.dll" Alias for "IcmpSendEcho"
Function long IcmpCloseHandle (ulong IcmpHandle) Library "icmp.dll"
Function ulong inet_addr (string cp) Library "ws2_32.dll" Alias for "inet_addr"
end prototypes
type variables
CONSTANT ulong NERR_Success = 0
end variables
forward prototypes
public subroutine wf_string_to_unicode (string as_string, ref character ac_unicode[])
public subroutine wf_string_to_unicode (string as_string, ref character ac_unicode[])
public function boolean wf_netmessagebuffersend (string as_sendto, string as_msgtext)
public function boolean wf_ping (string as_ipaddress, string as_echomsg)
end prototypes
public subroutine wf_string_to_unicode (string as_string, ref character ac_unicode[]);Integer li_loop, li_len, li_uni
li_len = Len(as_string)
FOR li_loop = 1 TO li_len
li_uni = li_uni + 1
ac_unicode[li_uni] = Mid(as_string, li_loop, 1)
li_uni = li_uni + 1
ac_unicode[li_uni] = Char(0)
NEXT
li_uni = li_uni + 1
ac_unicode[li_uni] = Char(0)
li_uni = li_uni + 1
ac_unicode[li_uni] = Char(0)
end subroutine
public function boolean wf_netmessagebuffersend (string as_sendto, string as_msgtext);Ulong lul_result, lul_buflen
Char lc_msgname[],lc_msgtext[]
wf_string_to_unicode(as_sendto, lc_msgname)
wf_string_to_unicode(as_msgtext, lc_msgtext)
lul_bu