ก่อนอื่นต้องสร้าง Structure ตามตัวอย่างครับ
name = str_wsadata
unsignedinteger version
unsignedinteger highversion
character description[257]
character systemstatus[129]
nsignedinteger maxsockets
unsignedinteger maxupddg
string vendorinfo
จากนั้นต้องประกาศ เรียก External function ครับ
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"
เขียน code ใช้งานตามนี้ครับ
String ls_ip, ls_host
Blob{4} lb_host
Integer li_version, li_rc
str_wsadata lstr_wsadata
ls_host = Space(128)
li_version = 257
If WSAStartup(li_version, lstr_wsadata) = 0 Then
If GetHostName(ls_host, Len(ls_host)) < 0 Then
li_rc = WSAGetLastError()
Else
GetHost(ls_host, lb_host)
ls_ip = String(Asc(String(BlobMid(lb_host, 1, 1)))) + "."
ls_ip += String(Asc(String(BlobMid(lb_host, 2, 1)))) + "."
ls_ip += String(Asc(String(BlobMid(lb_host, 3, 1)))) + "."
ls_ip += String(Asc(String(BlobMid(lb_host, 4, 1))))
li_rc = 0
End If
MessageBox("My IP", ls_ip)
Else
li_rc = WSAGetLastError()
End If
WSACleanup()
หาค่า IP address ของเครื่อง
Latest News
- บทที่ 7-1 ตอน การสร้างระบบฐานข้อมูล
- บทที่ 6 ทดลองเขียนโปรแกรมด้วย PocketBuilder เบื้องต้น
- บทที่ 4 ติดตั้งdatabase sql anywhere
- บทที่ 7-2 ตอน การสร้างโปรแกรมแสดงรายการอาหารที่สั่ง ด้วย Powerbuilder 9
- บทที่ 3 ติดตั้งอุปกรณ์ และโปรแกรม Active Sync
- ทำชุด setup โปรแกรมด้วย Wise Install
- การติดตั้ง IIS
- ตัวอย่าง code โปรแกรมร้านเช่า VDO
- สมาชิก : 2
- Content : 336
- เว็บลิงก์ : 8
- จำนวนครั้งเปิดดูบทความ : 159007


