(Co-Admin)
Registriert seit: 29. Mai 2002
Ort: Hamburg
11.117 Beiträge
Delphi 11 Alexandria
|
Re: Subnetzmaske/ Server finden
26. Okt 2003, 18:13
Moin EConvertError,
hier noch mal das Original komplett
Code:
const
MAX_ADAPTER_DESCRIPTION_LENGTH = 128; // arb.
MAX_ADAPTER_NAME_LENGTH = 256; // arb.
MAX_ADAPTER_ADDRESS_LENGTH = 8; // arb.
type
PIP_ADDRESS_STRING = ^IP_ADDRESS_STRING;
IP_ADDRESS_STRING =
packed record
acString : array [1..16] of Char;
end;
PIP_MASK_STRING = ^PIP_MASK_STRING;
IP_MASK_STRING = IP_ADDRESS_STRING;
PIP_ADDR_STRING = ^IP_ADDR_STRING;
IP_ADDR_STRING =
packed record
Next : PIP_ADDR_STRING;
IpAddress : IP_ADDRESS_STRING;
IpMask : IP_MASK_STRING;
Context : DWORD;
end;
time_t = int64;
PIP_ADAPTER_INFO = ^IP_ADAPTER_INFO;
IP_ADAPTER_INFO =
packed record
Next : PIP_ADAPTER_INFO;
ComboIndex : DWORD;
AdapterName : array [1..MAX_ADAPTER_NAME_LENGTH+4] of Char ;
Description : array [1..MAX_ADAPTER_DESCRIPTION_LENGTH+4] of Char;
AddressLength : UINT;
Address : array [1..MAX_ADAPTER_ADDRESS_LENGTH] of Byte;
Index : DWORD;
dwType : UINT;
DhcpEnabled : UINT;
CurrentIpAddress : PIP_ADDR_STRING;
IpAddressList : IP_ADDR_STRING;
GatewayList : IP_ADDR_STRING;
DhcpServer : IP_ADDR_STRING;
HaveWins : Boolean;
PrimaryWinsServer : IP_ADDR_STRING;
SecondaryWinsServer : IP_ADDR_STRING;
LeaseObtained : time_t;
LeaseExpires : time_t;
end;
function GetAdaptersInfo(const pAdapterInfo : PIP_ADAPTER_INFO;const pOutBufLen : PULONG) : DWORD; stdcall; external 'IPHLPAPI.DLL' name 'GetAdaptersInfo';
implementation
{$R *.DFM}
procedure TForm1.FormShow(Sender: TObject);
var
dwResult : DWORD;
dwLen : DWORD;
pAdapterWork : PIP_ADAPTER_INFO;
pAdapterList : PIP_ADAPTER_INFO;
iasWork : IP_ADDR_STRING;
begin
pAdapterList := nil;
dwLen := 0;
dwResult := GetAdaptersInfo(pAdapterList,@dwLen);
if dwResult = ERROR_BUFFER_OVERFLOW then
begin
pAdapterList := AllocMem(dwLen);
try
dwResult := GetAdaptersInfo(pAdapterList,@dwLen);
if dwResult = ERROR_SUCCESS then
begin
pAdapterWork := pAdapterList;
cobGateway.Clear;
repeat
ShowMessage(trim(pAdapterWork.Description));
iasWork := pAdapterWork.GatewayList; [color=red]// auf GatewayList durch IpAddressList austauschen[/color]
while iasWork.Next <> nil do
begin
cobGateway.Items.Add(trim(iasWork.IpAddress.acString)); [color=red]// und hier IpAddress durch IpMask[/color]
iasWork := iasWork.Next^;
end;
cobGateway.Items.Add(trim(iasWork.IpAddress.acString)); [color=red]// hier auch IpAddress durch IpMask tauschen[/color]
pAdapterWork := pAdapterWork.Next;
until pAdapterWork = nil;
if cobGateway.Items.Count > 0 then
begin
cobGateway.ItemIndex := 0;
end;
end;
finally
FreeMem(pAdapterList,dwLen);
end;
end;
end;
Tschüss Chris
Die drei Feinde des Programmierers: Sonne, Frischluft und dieses unerträgliche Gebrüll der Vögel.
Der Klügere gibt solange nach bis er der Dumme ist
|