1000分求能实现以下功能的程序源码。(0分)

  • 主题发起人 主题发起人 大傻子
  • 开始时间 开始时间
对不起 浪人情哥,你的程序不是我想要的。请看清我的要求好吗?
 
孺子不可教也
 
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
const
MAX_ADAPTER_DESCRIPTION_LENGTH = 128;
// arb.
MAX_ADAPTER_NAME_LENGTH = 256;
// arb.
MAX_ADAPTER_ADDRESS_LENGTH = 8;
// arb.
MAX_HOSTNAME_LEN =128;
MAX_DOMAIN_NAME_LEN = 128;
// arb.
MAX_SCOPE_ID_LEN = 256;
// arb.
NETBIOSTypes : array[0..8] of string[20] =
( 'UNKNOWN', 'BROADCAST', 'PEER_TO_PEER', '', 'MIXED', '', '', '', 'HYBRID'
);
type
time_t = Longint;
PIP_MASK_STRING = ^IP_MASK_STRING;
{$EXTERNALSYM PIP_MASK_STRING}
IP_ADDRESS_STRING = record
S: array [0..15] of Char;
end;
{$EXTERNALSYM IP_ADDRESS_STRING}
PIP_ADDRESS_STRING = ^IP_ADDRESS_STRING;
{$EXTERNALSYM PIP_ADDRESS_STRING}
IP_MASK_STRING = IP_ADDRESS_STRING;
{$EXTERNALSYM IP_MASK_STRING}
TIpAddressString = IP_ADDRESS_STRING;
PIpAddressString = PIP_MASK_STRING;
PIP_ADDR_STRING = ^IP_ADDR_STRING;
{$EXTERNALSYM PIP_ADDR_STRING}
_IP_ADDR_STRING = record
Next: PIP_ADDR_STRING;
IpAddress: IP_ADDRESS_STRING;
IpMask: IP_MASK_STRING;
Context: DWORD;
end;
{$EXTERNALSYM _IP_ADDR_STRING}
IP_ADDR_STRING = _IP_ADDR_STRING;
{$EXTERNALSYM IP_ADDR_STRING}
TIpAddrString = IP_ADDR_STRING;
PIpAddrString = PIP_ADDR_STRING;

PIP_ADAPTER_INFO = ^IP_ADAPTER_INFO;
{$EXTERNALSYM PIP_ADAPTER_INFO}
_IP_ADAPTER_INFO = record
Next: PIP_ADAPTER_INFO;
ComboIndex: DWORD;
AdapterName: array [0..MAX_ADAPTER_NAME_LENGTH + 3] of Char;
Description: array [0..MAX_ADAPTER_DESCRIPTION_LENGTH + 3] of Char;
AddressLength: UINT;
Address: array [0..MAX_ADAPTER_ADDRESS_LENGTH -1] of BYTE;
Index: DWORD;
Type_: UINT;
DhcpEnabled: UINT;
CurrentIpAddress: PIP_ADDR_STRING;
IpAddressList: IP_ADDR_STRING;
GatewayList: IP_ADDR_STRING;
DhcpServer: IP_ADDR_STRING;
HaveWins: BOOL;
PrimaryWinsServer: IP_ADDR_STRING;
SecondaryWinsServer: IP_ADDR_STRING;
LeaseObtained: time_t;
LeaseExpires: time_t;
end;
{$EXTERNALSYM _IP_ADAPTER_INFO}
IP_ADAPTER_INFO = _IP_ADAPTER_INFO;
{$EXTERNALSYM IP_ADAPTER_INFO}
TIpAdapterInfo = IP_ADAPTER_INFO;
PIpAdapterInfo = PIP_ADAPTER_INFO;
PFIXED_INFO = ^FIXED_INFO;
{$EXTERNALSYM PFIXED_INFO}
FIXED_INFO = record
HostName: array [0..MAX_HOSTNAME_LEN + 3] of Char;
do
mainName: array[0..MAX_DOMAIN_NAME_LEN + 3] of Char;
CurrentDnsServer: PIP_ADDR_STRING;
DnsServerList: IP_ADDR_STRING;
NodeType: UINT;
ScopeId: array [0..MAX_SCOPE_ID_LEN + 3] of Char;
EnableRouting: UINT;
EnableProxy: UINT;
EnableDns: UINT;
end;
{$EXTERNALSYM FIXED_INFO}
TFixedInfo = FIXED_INFO;
PFixedInfo = PFIXED_INFO;

type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

function GetAdaptersInfo(pAdapterInfo: PIP_ADAPTER_INFO;
var pOutBufLen: ULONG): DWORD;
stdcall;
external 'iphlpapi.dll' name 'GetAdaptersInfo';
function GetNetworkParams(pFixedInfo: PFIXED_INFO;
var pOutBufLen: ULONG): DWORD;
stdcall;
external 'iphlpapi.dll' name 'GetNetworkParams';
var
Form1: TForm1;
implementation
{$R *.dfm}
function MacAddrToStr( MacAddr: array of byte;
size: integer ): string;
var
i : integer;
begin
if Size = 0 then
begin
Result := '00-00-00-00-00-00';
EXIT;
end
else
Result := '';
for i := 0 to Size-1do
begin
Result := Result + IntToHex( MacAddr, 2 ) + '-';
end;
Delete( Result, Length( Result ), 1 );
end;

procedure Get_NetworkParams( List: TStrings );
var
FixedInfo : PFixed_Info;
InfoSize : ulong;
ErrorCode : DWORD;
I : Integer;
//DNS : PTIP_ADDR_STRING;
DNS : PIP_ADDR_STRING;
begin
if not Assigned( List ) then
EXIT;
List.Clear;
InfoSize := 5012;
GetMem(FixedInfo,infosize);
ErrorCode := GetNetworkParams( FixedInfo, InfoSize );
if ErrorCode = ERROR_SUCCESS then
begin
with FixedInfo^do
begin
List.Add( 'HOSTNAME : ' + string( HostName ) );
List.Add( 'DOMAIN : ' + string(do
mainName ) );
List.Add( 'SCOPE : ' + string( ScopeID ) );
List.Add( 'NETBIOS NODE TYPE : ' + NETBIOSTypes[NodeType] );
List.Add( 'ROUTING ENABLED :' + IntToStr( EnableRouting ) );
List.Add( 'PROXY ENABLED :' + IntToStr( EnableProxy ) );
List.Add( 'DNS ENABLED :' + IntToStr( EnableDNS ) );
end;
//获取域名解析服务器地址
DNS := @FixedInfo^.DNSServerList;
Repeat
List.Add('DNS '+IntToStr(I)+': '+strpas(DNS.IpAddress.S));
Inc(I);
DNS := DNS^.Next;
Until (DNS = nil);
end
else
List.Add( SysErrorMessage( ErrorCode ) );
end;

procedure TForm1.Button1Click(Sender: TObject);
var
Error,BufLen:DWORD;
AdapterInfo,NetCard : PIP_ADAPTER_INFO;
Descr,sLocalIP,GateWayIP,DHCPIP,AdName,MacAddr:String ;
i:Integer;
Size:Cardinal;
begin
size:=5120*4;
GetMem(AdapterInfo,size);
Error:=GetAdaptersInfo(AdapterInfo,size);
if Error=no_error then
begin
NetCard:=AdapterInfo;
i:=0;
repeat
with NetCard^do
begin
sLocalIP:=IpAddressList.IpAddress.S;
sLocalIP:=trim(sLocalIP);
MacAddr:=Format('%16s',[macaddrtostr(address,addresslength)]);
Memo1.Lines.Add('IP:'+sLocalIP+' Mac:'+MacAddr);
inc(i);
end;
NetCard:=NetCard^.Next;
until (NetCard=nil)
end;
FreeMem(AdapterInfo);
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
Get_NetworkParams(Memo1.Lines) ;
end;

end.
 
www.g.cn一大把源码
 
在局域网中能不能取得别的主机的网关?
 

Similar threads

后退
顶部