要加 NB30 单元function GetAdapterInfo(Lana: Char): String;
var
Adapter: TAdapterStatus;
NCB: TNCB;
begin
FillChar(NCB, SizeOf(NCB), 0);
NCB.ncb_command := Char(NCBRESET);
NCB.ncb_lana_num := Lana;
if Netbios(@NCB) <> Char(NRC_GOODRET) then
begin
Result := 'NotCard!';
Exit;
end; FillChar(NCB, SizeOf(NCB), 0);
NCB.ncb_command := Char(NCBASTAT);
NCB.ncb_lana_num := Lana;
NCB.ncb_callname := '*'; FillChar(Adapter, SizeOf(Adapter), 0);
NCB.ncb_buffer := @Adapter;
NCB.ncb_length := SizeOf(Adapter);
{
if Netbios(@NCB) <> Char(NRC_GOODRET) then
begin
Result := 'mac not found';
Exit;
end;
}Netbios(@NCB);
Result :=
IntToHex(Byte(Adapter.adapter_address[0]), 2) + '-' +
IntToHex(Byte(Adapter.adapter_address[1]), 2) + '-' +
IntToHex(Byte(Adapter.adapter_address[2]), 2) + '-' +
IntToHex(Byte(Adapter.adapter_address[3]), 2) + '-' +
IntToHex(Byte(Adapter.adapter_address[4]), 2) + '-' +
IntToHex(Byte(Adapter.adapter_address[5]), 2);
end;function GetMACAddress: string;
var
AdapterList: TLanaEnum;
NCB: TNCB;
begin
FillChar(NCB, SizeOf(NCB), 0);
NCB.ncb_command := Char(NCBENUM);
NCB.ncb_buffer := @AdapterList;
NCB.ncb_length := SizeOf(AdapterList);
Netbios(@NCB);
if Byte(AdapterList.length) > 0 then
begin
Result := GetAdapterInfo(AdapterList.lana[0]);
end
else
Result := 'NotCard!'; //=0 表示没有网卡
end;
解决方案 »
- access 求根据从表更新主表的SQL语句
- 这样的C++代码怎么转换为Delphi?
- stream 之间的互相拷贝问题?
- 存储过程的一个问题,请教大家,请进--------------------->>
- 请问:repaint、update、refresh这三者有什么区别
- 请问:怎样用adoquery删除数据表中的所有记录?
- 请问高手D7中Flash控件在哪个页面呢?怎么用呢?
- 请问怎样用ADOQUERY控件把MEMO控件的内容存入数据库,SQL语句怎样写?
- 外挂
- 请你帮助可以吗
- Report Machine,基于FastReport,并作了中国化的修改与功能强化,更适合中文报表!100%源码!欢迎下载使用。
- 贺马年!(送送送!!!...吗), 马上来,马上给!
好像是干这个用的。说明如下:
GetAdaptersInfo
The 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: Requires Windows 2000.
Windows 95/98: Requires Windows 98.
Header: Declared in Iphlpapi.h.//没有
Library: Use Iphlpapi.lib.//没有 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 linked list of adapters.
ComboIndex
This member is unused.
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: Requires Windows 2000.
Windows 95/98: Requires Windows 98.
Header: Declared in Iptypes.h.
File->New->(New Item)DLL->OK
就建好了一个 DLL 工程.
把我上面那两个函数拷到Begin end.中间。
function GetAdapterInfo(Lana: Char): String;
语句为什么?我是个VB程序员,不太懂Delphi。
SysUtils,
Classes,NB30; function GetAdapterInfo(Lana: Char): String; stdcall;
var
Adapter: TAdapterStatus;
NCB: TNCB;
begin
FillChar(NCB, SizeOf(NCB), 0);
NCB.ncb_command := Char(NCBRESET);
NCB.ncb_lana_num := Lana;
if Netbios(@NCB) <> Char(NRC_GOODRET) then
begin
Result := 'NotCard!';
Exit;
end; FillChar(NCB, SizeOf(NCB), 0);
NCB.ncb_command := Char(NCBASTAT);
NCB.ncb_lana_num := Lana;
NCB.ncb_callname := '*'; FillChar(Adapter, SizeOf(Adapter), 0);
NCB.ncb_buffer := @Adapter;
NCB.ncb_length := SizeOf(Adapter);
{
if Netbios(@NCB) <> Char(NRC_GOODRET) then
begin
Result := 'mac not found';
Exit;
end;
}Netbios(@NCB);
Result :=
IntToHex(Byte(Adapter.adapter_address[0]), 2) + '-' +
IntToHex(Byte(Adapter.adapter_address[1]), 2) + '-' +
IntToHex(Byte(Adapter.adapter_address[2]), 2) + '-' +
IntToHex(Byte(Adapter.adapter_address[3]), 2) + '-' +
IntToHex(Byte(Adapter.adapter_address[4]), 2) + '-' +
IntToHex(Byte(Adapter.adapter_address[5]), 2);
end; function GetMACAddress: string; stdcall;
var
AdapterList: TLanaEnum;
NCB: TNCB;
begin
FillChar(NCB, SizeOf(NCB), 0);
NCB.ncb_command := Char(NCBENUM);
NCB.ncb_buffer := @AdapterList;
NCB.ncb_length := SizeOf(AdapterList);
Netbios(@NCB);
if Byte(AdapterList.length) > 0 then
begin
Result := GetAdapterInfo(AdapterList.lana[0]);
end
else
Result := 'NotCard!'; //=0 表示没有网卡
end;EXPORTS //引出GetMACAddress函数
GetMACAddress;
END.