当前位置:首页
开发技术指南» 文章正文
    引言:
 

 

    摘要: 谢谢 wu_07(itsy bitsy spider) 和madking(不爱了),特在此送分 ......
    摘要: 无法显示 xml 页。 使用 xsl 样式表无法查看 xml 输入。请更正错误然后单击 刷新按钮,或以后重试。 -------------------------------------------------------------------------------- 系统未找到指定的资源。处理资源 file:///e:/expert/xsl/3.xsl 时出错。 ......


如何得到动态IP地址

一个对等局域网多台机器共用一条ADSL线,MODEM不是连在我的机器上的,我如何能得到外网的IP地址?使用哪个API?

NO.1   作者: wzucdos

Private   Type   HOSTENT  
        hName   As   Long  
        hAliases   As   Long  
        hAddrType   As   Integer  
        hLen   As   Integer  
        hAddrList   As   Long  
  End   Type  
   
  Private   Declare   Function   gethostbyname   Lib   "wsock32"   (ByVal   hostname   As   String)   As   Long  
  Private   Declare   Sub   CopyMemoryIP   Lib   "kernel32"   Alias   "RtlMoveMemory"   (hpvDest   As   Any,   ByVal   hpvSource   As   Long,   ByVal   cbCopy   As   Long)  
  Private   Declare   Function   GetComputerNameA   Lib   "kernel32"   (ByVal   lpBuffer   As   String,   nSize   As   Long)   As   Long  
   
   
  Public   Function   GetIPFromHostName(ByVal   sHostName   As   String)   As   String  
   
          Dim   ptrHosent       As   Long  
          Dim   Host                 As   HOSTENT  
          Dim   dwIPAddr         As   Long  
          Dim   tmpIPAddr()   As   Byte  
          Dim   I                       As   Integer  
          Dim   sIPAddr           As   String  
           
        ptrHosent   =   gethostbyname(sHostName   &   vbNullChar)  
   
        If   ptrHosent   <>   0   Then  
           
                  CopyMemoryIP   Host,   ptrHosent,   Len(Host)  
                  CopyMemoryIP   dwIPAddr,   Host.hAddrList,   4  
                  ReDim   tmpIPAddr(1   To   Host.hLen)  
                  CopyMemoryIP   tmpIPAddr(1),   dwIPAddr,   Host.hLen  
                  For   I   =   1   To   Host.hLen   -   1  
                          sIPAddr   =   sIPAddr   &   tmpIPAddr(I)   &   "."  
                  Next  
                  sIPAddr   =   sIPAddr   &   tmpIPAddr(I)  
                  GetIPFromHostName   =   sIPAddr  
                   
        End   If  
         
  End   Function  
   
  Public   Function   GetComputerName()   As   String  
        Dim   UserName   As   String   *   255  
   
        Call   GetComputerNameA(UserName,   255)  
        GetComputerName   =   Left$(UserName,   InStr(UserName,   Chr$(0))   -   1)  
  End   Function  
   
  ===========================  
   
  Private   Sub   Command1_Click()  
          MsgBox   GetComputerName   &   vbCrLf   &   GetIPFromHostName(GetComputerName)  
  End   Sub  
  试一试!!!!

NO.2   作者: planetike

C:\>tracert   218.77.39.97  
   
  Tracing   route   to   218.77.39.97   over   a   maximum   of   30   hops  
   
      1       <10   ms       <10   ms       <10   ms     192.168.1.1  
      2           *                 *                 *           Request   timed   out.  
      3         60   ms         60   ms         70   ms     218.77.39.97  
   
  Trace   complete.  
   
  C:\>


 ·实现自动压缩文件    »显示摘要«
    摘要: 我编写的一个程序中需要将文件压缩后进行传输,我要在delphi中自动压缩,不要用压缩软件压缩后再传输。请问如何自动压缩,然后自动打开。 如 1.txt 2.txt 压缩成 1.zip 打开时 1.zip 解压缩为 1.txt 2.txt ......
» 本期热门文章:

©2000-2007 All Rights Reserved. 最佳浏览:1024X768 MSIE