![]() |
![]() |
| Paypal | FTP | CCD | Buscar | Trucos | Trabajo | Foros |
|
|||||||
| Registrarse | FAQ | Miembros | Calendario | Guía de estilo | Temas de Hoy |
![]() |
|
|
Herramientas | Buscar en Tema | Desplegado |
|
#1
|
|||
|
|||
|
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. ![]() |
|
#2
|
||||
|
||||
|
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;
}
__________________
Los Estados Unidos parecen destinados por la Providencia para plagar la América de miserias a nombre de la libertad." Simón Bolívar (Carta al Coronel Inglés Patricio Cambell 05/08/1829). |
|
#3
|
|||
|
|||
|
Saludos
Si traducen este código a Delphi, por favor póngalo aquí...
Gracias de antemanos. |
|
#4
|
||||
|
||||
|
Quizá el truco http://www.clubdelphi.com/trucos/ind...=93&scrollb=88 alojado aquí mismo en el club delphi te pueda servir
__________________
Lecciones de mi Madre. Tema: modificación del comportamiento, "Pará de actuar como tu padre!" http://www.purodelphi.com/ http://www.nosolodelphi.com/ |
![]() |
|
|
|