GetAdaptersInfoThe GetAdaptersInfo function retrieves adapter information for the local computer.DWORD GetAdaptersInfo( PIP_ADAPTER_INFO pAdapterInfo, // buffer to receive data PULONG pOutBufLen // size of data returned ); Parameters pAdapterInfo [out] Pointer to a buffer that, , receives a linked list of IP_ADAPTER_INFO structures. pOutBufLen [in] Pointer to a ULONG variable that specifies the size of the buffer pointed to by the pAdapterInfo parameter. If this size is insufficient to hold the adapter information, GetAdaptersInfo fills in this variable with the required size, and returns an error code of ERROR_BUFFER_OVERFLOW. Return Values If the function succeeds, the return value is ERROR_SUCCESS.If the function fails, the return value is one of the following error codes.Value Meaning ERROR_BUFFER_OVERFLOW The buffer size indicated by the pOutBufLen parameter is too small to hold the adapter information. The pOutBufLen parameter points to the required size. ERROR_INVALID_PARAMETER The pOutBufLen parameter is NULL, or the calling process does not have read/write access to the memory pointed to by pOutBufLen, or the calling process does not have write access to the memory pointed to by the pAdapterInfo parameter. ERROR_NO_DATA No adapter information exists for the local computer. ERROR_NOT_SUPPORTED GetAdaptersInfo is not supported by the operating system running on the local computer. Other If the function fails, use FormatMessage to obtain the message string for the returned error. Requirements Windows NT/2000 or later: Requires Windows 2000 or later. Windows 95/98/Me: Requires Windows 98 or later. Header: Declared in Iphlpapi.h. Library: Use Iphlpapi.lib.See Also IP_ADAPTER_INFO IP_ADAPTER_INFO The IP_ADAPTER_INFO structure contains information about a particular network adapter on the local computer.typedef struct _IP_ADAPTER_INFO { struct _IP_ADAPTER_INFO* Next; DWORD ComboIndex; char AdapterName[MAX_ADAPTER_NAME_LENGTH + 4]; char Description[MAX_ADAPTER_DESCRIPTION_LENGTH + 4]; UINT AddressLength; BYTE Address[MAX_ADAPTER_ADDRESS_LENGTH]; DWORD Index; UINT Type; UINT DhcpEnabled; PIP_ADDR_STRING CurrentIpAddress; IP_ADDR_STRING IpAddressList; IP_ADDR_STRING GatewayList; IP_ADDR_STRING DhcpServer; BOOL HaveWins; IP_ADDR_STRING PrimaryWinsServer; IP_ADDR_STRING SecondaryWinsServer; time_t LeaseObtained; time_t LeaseExpires; } IP_ADAPTER_INFO, *PIP_ADAPTER_INFO; Members Next Pointer to the next adapter in the list of adapters. ComboIndex Reserved. AdapterName[MAX_ADAPTER_NAME_LENGTH + 4] Specifies the name of the adapter. Description[MAX_ADAPTER_DESCRIPTION_LENGTH + 4] Specifies a description for the adapter. AddressLength Specifies the length of the hardware address for the adapter. Address[MAX_ADAPTER_ADDRESS_LENGTH] Specifies the hardware address for the adapter. Index Specifies the adapter index. Type Specifies the adapter type. DhcpEnabled Specifies whether dynamic host configuration protocol (DHCP) is enabled for this adapter. CurrentIpAddress Specifies the current IP address for this adapter. IpAddressList Specifies the list of IP addresses associated with this adapter. GatewayList Specifies the IP address of the default gateway for this adapter. DhcpServer Specifies the IP address of the DHCP server for this adapter. HaveWins Specifies whether this adapter uses Windows Internet Name Service (WINS). PrimaryWinsServer Specifies the IP address of the primary WINS server. SecondaryWinsServer Specifies the IP address of the secondary WINS server. LeaseObtained Specifies the time when the current DHCP lease was obtained. LeaseExpires Specifies the time when the current DHCP lease will expire. Requirements Windows NT/2000 or later: Requires Windows 2000 or later. Windows 95/98/Me: Requires Windows 98 or later. Header: Declared in Iptypes.h.See Also GetAdaptersInfo
Hi,恶人:Thank you for your reply!请问: ◎ 如何区分“拨号网络适配器”等?(如果单是一个拨号网络倒好办,但不一定),另外我不知道这个函数会否枚举出MiniPort Driver ◎ 没有IP协议是否能工作 ◎ i will try
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls,filectrl, ExtCtrls;type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
StaticText1: TStaticText;
Panel1: TPanel;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation
var
temp:string;
{$R *.DFM}procedure TForm1.Button1Click(Sender: TObject);
begin
memo1.Lines.Clear ;
if fileexists(temp) then
deletefile(temp);
//每次查询前将前次结果清除,上面三个清空或删除语句保证了多次查询时每次得到的都是最新查询的结果。
winexec(pchar('command.com /C ipconfig /all >'+temp),sw_hide);
//执行命令将查询结果存到临时文件temp,sw_hide指定将DOS界面隐藏。
while not fileexists(temp) do
sleep(1000);
//为了临时文件的建立等待1秒种try
memo1.lines.loadfromfile(temp);
except
//此处不写任何代码,即关闭任何异常。
end;
end;procedure TForm1.FormCreate(Sender: TObject);
begin
memo1.lines.Clear;
temp:='c:\temp.txt';
end;procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
if fileexists(temp) then
deletefile(temp);
end;end.
都是给出NetBIOS之类的结果,要么是HD序列号对我来说没用。本来如果强制用户装网卡的话可以,但我的思路是:
有网卡就用网卡,没网卡才用其他(例如HD/Video/OSid/CPUID)但我没行得通的网卡安装判断程序!
(不要说拨号网络),就没招,还有,tcp/ip协议不一定都装,早期Windows95就没有!
如果WIN下的命令不行,还有什么更通用的?
依靠这种方法,还不如使用Registry来枚举直接,虽然9x/NT位置不一样。
我不能要求、保证用户安装了tcp/ip协议。
PIP_ADAPTER_INFO pAdapterInfo, // buffer to receive data
PULONG pOutBufLen // size of data returned
);
Parameters
pAdapterInfo
[out] Pointer to a buffer that, , receives a linked list of IP_ADAPTER_INFO structures.
pOutBufLen
[in] Pointer to a ULONG variable that specifies the size of the buffer pointed to by the pAdapterInfo parameter. If this size is insufficient to hold the adapter information, GetAdaptersInfo fills in this variable with the required size, and returns an error code of ERROR_BUFFER_OVERFLOW.
Return Values
If the function succeeds, the return value is ERROR_SUCCESS.If the function fails, the return value is one of the following error codes.Value Meaning
ERROR_BUFFER_OVERFLOW The buffer size indicated by the pOutBufLen parameter is too small to hold the adapter information. The pOutBufLen parameter points to the required size.
ERROR_INVALID_PARAMETER The pOutBufLen parameter is NULL, or the calling process does not have read/write access to the memory pointed to by pOutBufLen, or the calling process does not have write access to the memory pointed to by the pAdapterInfo parameter.
ERROR_NO_DATA No adapter information exists for the local computer.
ERROR_NOT_SUPPORTED GetAdaptersInfo is not supported by the operating system running on the local computer.
Other If the function fails, use FormatMessage to obtain the message string for the returned error.
Requirements
Windows NT/2000 or later: Requires Windows 2000 or later.
Windows 95/98/Me: Requires Windows 98 or later.
Header: Declared in Iphlpapi.h.
Library: Use Iphlpapi.lib.See Also
IP_ADAPTER_INFO IP_ADAPTER_INFO
The IP_ADAPTER_INFO structure contains information about a particular network adapter on the local computer.typedef struct _IP_ADAPTER_INFO {
struct _IP_ADAPTER_INFO* Next;
DWORD ComboIndex;
char AdapterName[MAX_ADAPTER_NAME_LENGTH + 4];
char Description[MAX_ADAPTER_DESCRIPTION_LENGTH + 4];
UINT AddressLength;
BYTE Address[MAX_ADAPTER_ADDRESS_LENGTH];
DWORD Index;
UINT Type;
UINT DhcpEnabled;
PIP_ADDR_STRING CurrentIpAddress;
IP_ADDR_STRING IpAddressList;
IP_ADDR_STRING GatewayList;
IP_ADDR_STRING DhcpServer;
BOOL HaveWins;
IP_ADDR_STRING PrimaryWinsServer;
IP_ADDR_STRING SecondaryWinsServer;
time_t LeaseObtained;
time_t LeaseExpires;
} IP_ADAPTER_INFO, *PIP_ADAPTER_INFO;
Members
Next
Pointer to the next adapter in the list of adapters.
ComboIndex
Reserved.
AdapterName[MAX_ADAPTER_NAME_LENGTH + 4]
Specifies the name of the adapter.
Description[MAX_ADAPTER_DESCRIPTION_LENGTH + 4]
Specifies a description for the adapter.
AddressLength
Specifies the length of the hardware address for the adapter.
Address[MAX_ADAPTER_ADDRESS_LENGTH]
Specifies the hardware address for the adapter.
Index
Specifies the adapter index.
Type
Specifies the adapter type.
DhcpEnabled
Specifies whether dynamic host configuration protocol (DHCP) is enabled for this adapter.
CurrentIpAddress
Specifies the current IP address for this adapter.
IpAddressList
Specifies the list of IP addresses associated with this adapter.
GatewayList
Specifies the IP address of the default gateway for this adapter.
DhcpServer
Specifies the IP address of the DHCP server for this adapter.
HaveWins
Specifies whether this adapter uses Windows Internet Name Service (WINS).
PrimaryWinsServer
Specifies the IP address of the primary WINS server.
SecondaryWinsServer
Specifies the IP address of the secondary WINS server.
LeaseObtained
Specifies the time when the current DHCP lease was obtained.
LeaseExpires
Specifies the time when the current DHCP lease will expire.
Requirements
Windows NT/2000 or later: Requires Windows 2000 or later.
Windows 95/98/Me: Requires Windows 98 or later.
Header: Declared in Iptypes.h.See Also
GetAdaptersInfo
◎ 如何区分“拨号网络适配器”等?(如果单是一个拨号网络倒好办,但不一定),另外我不知道这个函数会否枚举出MiniPort Driver
◎ 没有IP协议是否能工作
◎ i will try
好象不支持nt