Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Internet (https://www.clubdelphi.com/foros/forumdisplay.php?f=3)
-   -   Como obtengo las direcciones IP de mi red (obviamente en delphi) (https://www.clubdelphi.com/foros/showthread.php?t=26737)

hkdatabis 02-11-2005 01:47:02

Como obtengo las direcciones IP de mi red (obviamente en delphi)
 
Estoy tratando de realizar un juego que sera en red (cliente/servidor, utilizando ClienteSocket y ServerSocket).
Ya en el juego para empezar, necesito obtener mis direcciones IP para poder contactarme con otro jugador.

Y ahi esta el problema por que no se como hacerle para obtener todas las direcciones ip de mi red, si alguien me pudiera ayudar con algun codigo que le sobrara o que me dijera que necesito hacer.

Gracias por su ayuda.:confused:

OSKR 16-11-2005 16:04:42

ahi estan los nombres de las maquinas....en un edit metes el nombre DNS o NeTBIOS del controlador de dominio y en el otro edit metes el nombre del dominio, esta en builder como puedes ver pero no sera gran problema q lo pases a Delphi
Código:

void __fastcall TForm1::Button3Click(TObject *Sender)
{ NET_API_STATUS nStatus;
  wchar_t *Servername;
  DWORD level;
  void *bufptr;
  DWORD prefmaxlen;
  DWORD entriesread;
  DWORD totalentries;
  DWORD servertype;
  LPWSTR domain;
  DWORD resume_handle;
  //--------------------
  Servername = new wchar_t[Edit1->Text.Trim().Length()+1];
  Edit1->Text.Trim().WideChar(Servername,Edit1->Text.Trim().WideCharBufSize());
  level=101L;
  prefmaxlen=32*1024;
  servertype=SV_TYPE_WORKSTATION;
  domain = new wchar_t[Edit2->Text.Trim().Length()+1];
  Edit2->Text.Trim().WideChar(domain,Edit2->Text.Trim().WideCharBufSize());
  resume_handle=0;
  do
  { nStatus = NetServerEnum(Servername,level,(LPBYTE *)&bufptr,prefmaxlen,&entriesread,&totalentries,servertype,domain,&resume_handle);
        if((nStatus == NERR_Success) || (nStatus == ERROR_MORE_DATA))
          { SERVER_INFO_101 *SI101=(SERVER_INFO_101 *)bufptr;
                for(int i = 0; (i < entriesread); i++)
                  { Memo1->Lines->Add("//--------------------------------------");
                        Memo1->Lines->Add("Nombre: "+AnsiString(SI101[i].sv101_name));
                        Memo1->Lines->Add("Id: "+AnsiString(SI101[i].sv101_platform_id));
                        Memo1->Lines->Add("Comment: "+AnsiString(SI101[i].sv101_comment));
                  }
          }
        else
          { LPVOID lpMsgBuf;
                FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,NULL,GetLastError(),MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),(LPTSTR) &lpMsgBuf,0,NULL);
                MessageBox( NULL,(char *)lpMsgBuf, "GetLastError", MB_OK|MB_ICONINFORMATION);
                LocalFree( lpMsgBuf );
          }
        if(nStatus == ERROR_ACCESS_DENIED)
          { ShowMessage("Sin permisos...");
                break;
          }
        if(nStatus == NERR_InvalidComputer)
          { ShowMessage("Pote inválido");
                break;
          }
        if(nStatus == ERROR_NO_BROWSER_SERVERS_FOUND)
          { ShowMessage("ERROR_NO_BROWSER_SERVERS_FOUND");
                break;
          }
  }while(nStatus == ERROR_MORE_DATA);
  if(bufptr)
        NetApiBufferFree(bufptr);
  delete [] Servername;
  delete [] domain;
}


Roilo 15-02-2007 21:13:21

Saludos
 
Si traducen este código a Delphi, por favor póngalo aquí...
Gracias de antemanos.

jhonny 15-02-2007 21:53:30

Quizá el truco http://www.clubdelphi.com/trucos/ind...=93&scrollb=88 alojado aquí mismo en el club delphi te pueda servir


La franja horaria es GMT +2. Ahora son las 12:05:15.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi