yebin5151 发表于 2007-6-21 08:53

请问:PB如何获得计算机的IP地址和MAC

想请教一个问题,怎么获得计算机的IP地址和MAC地址呢?

路過 发表于 2007-6-21 09:57

以後在站內找一下<a href="http://bbs.bc-cn.net/viewthread.php?tid=91786&amp;star=at" target="_blank" ><BR>http://bbs.bc-cn.net/viewthread.php?tid=91786&amp;star=at</A>#

sam2080 发表于 2007-6-28 16:22

<P>取得IP地址的方法:     <BR>    <BR>  1、定义一个名为s_wsadata的结构,如下:   <BR>    <BR>      unsignedinteger           version   <BR>    <BR>      unsignedinteger           highversion   <BR>    <BR>      character                       discription[257]   <BR>    <BR>      character                       systemstatus[129]   <BR>    <BR>      unsignedinteger           maxsockets   <BR>    <BR>      unsignedinteger           maxupddg   <BR>    <BR>      string                             vendorinfo   <BR>    <BR>  二、在Local   External   Funtions中作如下的声明:   <BR>    <BR>        function   int   WSAStartup(   uint   UIVersionRequested,   ref   s_WSAData   lpWSAData   )     library   "wsock32.dll"   <BR>    <BR>          function   int   WSACleanup()   library   "wsock32.dll"   <BR>    <BR>          function   int   WSAGetLastError   (   )   library   "wsock32.dll"   <BR>    <BR>          function   int   gethostname   (   ref   string   name,   int   namelen   )   library   "wsock32.dll"   <BR>    <BR>          function   string   GetHost(string   lpszhost,   ref   blob   lpszaddress   )   library   "pbws32.dll"     <BR>    <BR>    <BR>  三、使用方法:   <BR>    <BR>  s_wsadata                   l_WSAData   <BR>    <BR>  string ls_HostName   =   space(128)         <BR>    <BR>  string ls_IpAddress   <BR>    <BR>  int li_version   =   257   <BR>    <BR>  blob{4}   lb_hostaddress     <BR>    <BR>    <BR>  IF   wsastartup   (   li_version,   l_WSAData   )   =   0   THEN   <BR>    <BR>  IF   gethostname   (   ls_HostName,   len(ls_HostName)   )   &lt;   0   THEN   <BR>    <BR>  messagebox("GetHostName",WSAGetLastError())   <BR>    <BR>  ELSE   <BR>    <BR>    <BR>  GetHost(ls_HostName,   lb_HostAddress)   <BR>    <BR>  ls_IpAddress   =   string(asc(string(blobmid(lb_HostAddress,1,1))),"000")   +   "."   <BR>    <BR>  ls_IpAddress   +=   string(asc(string(blobmid(lb_HostAddress,2,1))),"000")   +   "."   <BR>    <BR>  ls_IpAddress   +=   string(asc(string(blobmid(lb_HostAddress,3,1))),"000")   +   "."   <BR>    <BR>  ls_IpAddress   +=   string(asc(string(blobmid(lb_HostAddress,4,1))),"000")   <BR>    <BR>    <BR>  END   IF   <BR>    <BR>    <BR>  WSACleanup()   <BR>    <BR>  ELSE   <BR>    <BR>  messagebox("GetHostName",WSAGetLastError())   <BR>    <BR>  END   IF     <BR>    <BR>    <BR>  messagebox('ls_hostname:   '+ls_hostname,'ls_ipaddress:   '+ls_ipaddress) </P>获取MAC地址请看附件中的DLL及PBL

[attach]23263[/attach]<BR>

页: [1]

编程论坛