五彩積水鳳梨花

五彩積水鳳梨花
五彩積水鳳梨花

2010/01/28

TCP/IP ADDRESS

TCP/IP ADDRESS

Structure: str_wsadata

unsignedinteger version

unsignedinteger highversion

character description[257]

character systemstatus[129]

nsignedinteger maxsockets

unsignedinteger maxupddg

string vendorinfo

External function declarations:

function int WSAStartup (uint UIVerionrequested, ref str_wsadata lpWSAdata)library "wsock32.DLL"

function int WSACleanup() library "wsock32.DLL"

function int WSAGetLastError() library "wsock32.DLL"

function int gethostname(ref string name, int namelen) library "wsock32.DLL"

function string GetHost(string lpszhost,ref blob lpszaddress) library "pbws32.dll"

PowerScript code:

String ls_ipaddress, ls_hostname

Blob{4} lb_hostadress

Integer li_version, li_rc

str_wsadata lstr_wsadata

ls_hostname = Space(128)

li_version = 257

If WSAStartup(li_version, lstr_wsadata) = 0 Then

If GetHostName(ls_hostname, Len(ls_hostname)) <>

li_rc = WSAGetLastError()

Else

GetHost(ls_hostname, lb_hostadress)

ls_ipaddress = String(Asc(String(BlobMid(lb_hostadress, 1, 1)))) + "."

ls_ipaddress += String(Asc(String(BlobMid(lb_hostadress, 2, 1)))) + "."

ls_ipaddress += String(Asc(String(BlobMid(lb_hostadress, 3, 1)))) + "."

ls_ipaddress += String(Asc(String(BlobMid(lb_hostadress, 4, 1))))

li_rc = 0

End If

Else

li_rc = WSAGetLastError()

End If

WSACleanup()

1 則留言:

灰太狼 提到...

目前使用此方是有些機器會抓不到 IP 尋求更好的方式中