您的位置:首页 > Web前端

如何调用NetMessageBufferSend发送消息?(改编)

2008-04-26 15:13 543 查看
如何调用NetMessageBufferSend发送消息

问题描述:

如何调用WINNT/2K/XP下的API函数NetMessageBufferSend模拟netsend命令来发送消息

解决方案:

下面代码已测试成功,直接导入PBL即可

$PBExportHeader$w_main.srw

forward

globaltypew_mainfromWindow

endtype

typemle_1frommultilineeditwithinw_main

endtype

typecb_1fromcommandbuttonwithinw_main

endtype

typesle_1fromsinglelineeditwithinw_main

endtype

typest_2fromstatictextwithinw_main

endtype

typest_1fromstatictextwithinw_main

endtype

endforward

typeicmp_echo_replyfromstructure

unsignedlong address

unsignedlong status

unsignedlong roundtriptime

unsignedlong datasize

unsignedlong reserved[3]

character data[250]

endtype

globaltypew_mainfromWindow

intX=1056

intY=484

intWidth=1531

intHeight=1152

booleanTitleBar=true

stringTitle="NETMESSAGESEND"

longBackColor=80269524

booleanControlMenu=true

booleanMinBox=true

booleanResizable=true

mle_1mle_1

cb_1cb_1

sle_1sle_1

st_2st_2

st_1st_1

endtype

globalw_mainw_main

typeprototypes

FunctionulongNetMessageBufferSend(ulongservername,refcharmsgname[],ulongfromname,refcharbuf[],ulongbuflen)Library"netapi32.dll"Aliasfor"NetMessageBufferSend"

FunctionulongIcmpCreateFile()Library"icmp.dll"

FunctionlongIcmpSendEcho(ulongIcmpHandle,ulongDestinationAddress,stringRequestData,longRequestSize,longRequestOptions,Reficmp_echo_replyReplyBuffer,longReplySize,longTimeout)Library"icmp.dll"Aliasfor"IcmpSendEcho"

FunctionlongIcmpCloseHandle(ulongIcmpHandle)Library"icmp.dll"

Functionulonginet_addr(stringcp)Library"ws2_32.dll"Aliasfor"inet_addr"

endprototypes

typevariables

CONSTANTulongNERR_Success=0

endvariables

forwardprototypes

publicsubroutinewf_string_to_unicode(stringas_string,refcharacterac_unicode[])

publicsubroutinewf_string_to_unicode(stringas_string,refcharacterac_unicode[])

publicfunctionbooleanwf_netmessagebuffersend(stringas_sendto,stringas_msgtext)

publicfunctionbooleanwf_ping(stringas_ipaddress,stringas_echomsg)

endprototypes

publicsubroutinewf_string_to_unicode(stringas_string,refcharacterac_unicode[]);Integerli_loop,li_len,li_uni

li_len=Len(as_string)

FORli_loop=1TOli_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)

endsubroutine

publicfunctionbooleanwf_netmessagebuffersend(stringas_sendto,stringas_msgtext);Ulonglul_result,lul_buflen1
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐