国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

如何調用NetMessageBufferSend發送消息?(改編)

2024-07-21 02:06:05
字體:
來源:轉載
供稿:網友



如何調用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_buflen = upperbound(lc_msgtext)

 

lul_result = netmessagebuffersend(0, lc_msgname,0, lc_msgtext, lul_buflen)

 

if lul_result = nerr_success then

    return true

else

    return false

end if

end function

public function boolean wf_ping (string as_ipaddress, string as_echomsg);ulong lul_address, lul_handle

long ll_rc, ll_size

string ls_reply

icmp_echo_reply lstr_reply

 

lul_address = inet_addr(as_ipaddress)

if lul_address > 0 then

    lul_handle = icmpcreatefile()

    ll_size = len(as_echomsg)

    ll_rc = icmpsendecho(lul_handle, lul_address, &

                        as_echomsg, ll_size, 0, &

                        lstr_reply, 278, 200)

    icmpclosehandle(lul_handle)

    if ll_rc <> 0 then

        if lstr_reply.status = 0 then

            ls_reply = string(lstr_reply.data)

            if ls_reply = as_echomsg then

                return true

            end if

        end if

    end if

end if

 

return false

 

end function

on w_main.create

this.mle_1=create mle_1

this.cb_1=create cb_1

this.sle_1=create sle_1

this.st_2=create st_2

this.st_1=create st_1

this.control[]={this.mle_1,&

this.cb_1,&

this.sle_1,&

this.st_2,&

this.st_1}

end on

 

on w_main.destroy

destroy(this.mle_1)

destroy(this.cb_1)

destroy(this.sle_1)

destroy(this.st_2)

destroy(this.st_1)

end on

 

type mle_1 from multilineedit within w_main

int x=27

int y=264

int width=1399

int height=604

int taborder=20

borderstyle borderstyle=stylelowered!

long textcolor=33554432

int textsize=-10

int weight=400

string facename="方正姚體"

fontcharset fontcharset=gb2312charset!

fontpitch fontpitch=variable!

end type

 

type cb_1 from commandbutton within w_main

int x=1070

int y=904

int width=357

int height=108

int taborder=30

string text=" 發送(&s)"

int textsize=-10

int weight=400

string facename="方正姚體"

fontcharset fontcharset=gb2312charset!

fontpitch fontpitch=variable!

end type

 

event clicked;if not wf_ping(trim(sle_1.text),"") then

    messagebox("提示","指定目標地址不存在或不通!")

    return

end if

 

if wf_netmessagebuffersend(trim(sle_1.text),trim(mle_1.text)) then

   messagebox("提示","發送成功!")

else

   messagebox("提示","發送失敗!")  

end if

end event

type sle_1 from singlelineedit within w_main

int x=430

int y=48

int width=997

int height=92

int taborder=10

borderstyle borderstyle=stylelowered!

boolean autohscroll=false

long textcolor=33554432

int textsize=-10

int weight=400

string facename="方正姚體"

fontcharset fontcharset=gb2312charset!

fontpitch fontpitch=variable!

end type

 

type st_2 from statictext within w_main

int x=14

int y=172

int width=379

int height=76

boolean enabled=false

string text="發送內容:"

boolean focusrectangle=false

long textcolor=33554432

long backcolor=67108864

int textsize=-10

int weight=400

string facename="方正姚體"

fontcharset fontcharset=gb2312charset!

fontpitch fontpitch=variable!

end type

 

type st_1 from statictext within w_main

int x=14

int y=52

int width=379

int height=76

boolean enabled=false

string text="目標地址:"

boolean focusrectangle=false

long textcolor=33554432

long backcolor=67108864

int textsize=-10

int weight=400

string facename="方正姚體"

fontcharset fontcharset=gb2312charset!

fontpitch fontpitch=variable!

end type

 
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 景谷| 双桥区| 盐源县| 大悟县| 平凉市| 玛沁县| 建湖县| 嘉荫县| 连平县| 堆龙德庆县| 清苑县| 买车| 枣阳市| 米易县| 如皋市| 理塘县| 龙南县| 西华县| 平昌县| 定南县| 鹰潭市| 禄丰县| 阿城市| 琼结县| 城口县| 马公市| 永宁县| 元氏县| 揭阳市| 棋牌| 庄浪县| 梁平县| 桐庐县| 敖汉旗| 读书| 安岳县| 砀山县| 清丰县| 崇左市| 洛扎县| 舞钢市|