zoukankan      html  css  js  c++  java
  • InstallShield高级应用获得本机的IP地址

    直接给出源代码,有问题的欢迎交流。

    ///////////////////////////////////////////////////////////////////////////////
    //
    // Tcp/Ip function GetLocalIP
    //
    // By: chhuic 2010-12-26
    //
    //
    ///////////////////////////////////////////////////////////////////////////////

    #define WSADESCRIPTION_LEN 256
    #define WSASYS_STATUS_LEN 128

    typedef
    WSAData
    begin
    INT wVersion;
    INT wHighVersion;
    string szDescription[WSADESCRIPTION_LEN+1];
    string szSystemStatus[WSASYS_STATUS_LEN+1];
    short iMaxSockets;
    short iMaxUdpDg;
    POINTER lpVendorInfo;
    end;
    ////////////////////
    typedef HostEnt
    begin
    POINTER ph_name; /* official name of host */
    POINTER ph_aliases; /* alias list */
    short h_addrtype; /* host address type */
    short h_length; /* length of address */
    POINTER ph_addr_list; /* list of addresses */
    end;

    //////////////////
    typedef IPName
    begin
    STRING szIPAddr[100];
    end;
    /////////////

    typedef IPAddrList
    begin
    POINTER pIPAddr;
    end;

    /////////////

    typedef IPAddPtr
    begin
    LONG nIPAddr;
    end;
    /////////////


    prototype POINTER wsock32.gethostbyname(BYREF STRING);
    prototype POINTER wsock32.gethostname(BYREF STRING, NUMBER);
    prototype POINTER wsock32.WSAStartup(INT, POINTER);
    prototype POINTER wsock32.inet_ntoa( NUMBER);
    prototype POINTER wsock32.WSACleanup();
    prototype int wsock32.WSAGetLastError ();
    prototype STRING GetLocalIP();

    function STRING GetLocalIP()
    WSAData structWSAData;
    WSAData POINTER pWSAData;
    //
    IPName LocalIPName;
    IPName POINTER pLocalIPName;
    //
    IPAddrList structIPAddrList;
    IPAddrList POINTER pIPAddrList;
    IPAddPtr structIPAddPtr;
    IPAddPtr POINTER pIPAddPtr;

    POINTER pIN_Addr_Struct;
    HostEnt structHostEnt;
    HostEnt POINTER pHostEnt;
    SHORT nlen;
    NUMBER nIPNetAddr;

    NUMBER nVersion;
    STRING szMsg;
    STRING szDefault;
    STRING szURL;
    STRING szPath;
    NUMBER nRC;
    NUMBER nRC2;
    STRING szHostName;
    STRING szMYIPAddr;
    POINTER pWinSockReturn;

    begin
    pWSAData = &structWSAData;

    nRC = UseDLL ("wsock32.dll");
    pWSAData -> wHighVersion = 1;
    pWSAData -> wVersion = 1;
    nVersion = 0x02000002; // can be 0x01000001 for Windows NT but Windows 95 requires the version 2 settings

    pWinSockReturn = WSAStartup(nVersion, pWSAData);
    pWinSockReturn = gethostname(szHostName,100);
    pHostEnt = gethostbyname(szHostName);

    nlen = pHostEnt -> h_length; // debug check (should be 4)
    pIPAddPtr = pHostEnt -> ph_addr_list;
    pIPAddPtr = *pIPAddPtr;
    nIPNetAddr = *pIPAddPtr;
    // nIPNetAddr = pIPAddPtr -> nIPAddr;
    pLocalIPName = inet_ntoa( nIPNetAddr );
    szMYIPAddr = pLocalIPName -> szIPAddr;
    WSACleanup();
    UnUseDLL("wsock32.dll");
    return szMYIPAddr;
    end;

  • 相关阅读:
    如何从svn上down项目
    查看当前项目的svn地址
    项目启动失败
    新增sql后面可以跟where条件(多表关联新增数据和复制数据)
    递归思想之---斐波拉契数列
    递归思想之---阶乘算法
    java递归思想之---汉诺塔
    将 Docker 镜像体积减小 转载:https://mp.weixin.qq.com/s/kyK6652kchtudZHhSsYx_Q
    工具 转载 https://mp.weixin.qq.com/s/Y1RHEDu0vuH4qm9QtMISFg
    Kubernetes 学习笔记 权威指南第五&六章
  • 原文地址:https://www.cnblogs.com/chhuic/p/2072703.html
Copyright © 2011-2022 走看看