Показать сообщение отдельно
Старый 23.12.2005, 14:18   #2  
AndyD is offline
AndyD
Участник
КОРУС Консалтинг
Лучший по профессии 2015
Лучший по профессии 2014
Лучший по профессии AXAWARD 2013
Лучший по профессии 2011
 
2,560 / 2476 (88) +++++++++
Регистрация: 20.08.2005
X++:
static void GetClientIP(Args _args)
{
    xSession session = new xSession();
    container   Addr;
    int         k;

    container GetHostByName(str Host)
    {
        DLL         dll = new DLL("Ws2_32.dll");
        DLLFunction _getHostByName = new DLLFunction(dll, "gethostbyname");
        DLLFunction _inet_ntoa = new DLLFunction(dll, "inet_ntoa");
        int         Hostent;
        Binary      bin = new Binary(16);
        Binary      h, h1;
        int         i;
        container   c = connull();
        str         s;
        ;
        _getHostByName.arg(ExtTypes::String);
        _getHostByName.returns(ExtTypes::DWord);
        Hostent = _getHostByName.Call(Host);
        if (Hostent)
        {
            bin.attach(Hostent, 16);
            if (bin.word(8) == 2 && bin.word(10) == 4)
            {
                h = new Binary(4*251);
                h.attach(bin.DWord(12), 4*251);

                _inet_ntoa.arg(ExtTypes::DWord);
                _inet_ntoa.returns(ExtTypes::String);
                h1 = new Binary(bin.word(10));
                for (i=0;h.DWord(i);i+=4)
                {
                    h1.attach(h.DWord(i), bin.word(10));
                    s = _inet_ntoa.call(h1.DWord(0));
                    if (s)
                        c += [s];
                }
            }
        }
        return c;
    }
    ;
    Addr = GetHostByName(Session.clientComputerName());
    for (k=1;k<=ConLen(Addr);k++)
        info(ConPeek(Addr, k));
}
__________________
Axapta v.3.0 sp5 kr2
За это сообщение автора поблагодарили: raz (3), belugin (1), kashperuk (2), alex55 (1).