Wielkie dzięki ŁF
Wyciąłem z tego co mi było potrzeba i wyszło to:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, registry, clipbrd,
Menus, StdCtrls;
type
TIP_ADAPTER_INDEX_MAP = packed record
index : longint;
Name : wchar;
end;
TIP_INTERFACE_INFO = packed record
NumAdapters : LONGINT;
Adapter : array[0..32768] of ^TIP_ADAPTER_INDEX_MAP;
end;
PIP_INTERFACE_INFO = ^TIP_INTERFACE_INFO;
const
MAX_ADAPTER_DESCRIPTION_LENGTH = 128; // arb.
MAX_ADAPTER_NAME_LENGTH = 256; // arb.
MAX_ADAPTER_ADDRESS_LENGTH = 8; // arb.
type
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;
end;
type
TForm1 = class(TForm)
Card: TEdit;
Pobierz: TButton;
procedure PobierzClick(Sender: TObject);
private
ial : array of PIP_ADAPTER_INFO;
ia : PIP_ADAPTER_INFO;
cnt : ulong;
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure die(const msg : string);
begin
ShowMessage(msg);
halt(1);
end;
function GetAdaptersInfo(
pAdapterInfo : PIP_ADAPTER_INFO;
pOutBufLen : PULONG
) : DWORD; stdcall; external 'IPHLPAPI.DLL' name 'GetAdaptersInfo';
procedure TForm1.PobierzClick(Sender: TObject);
var i: integer;
begin
cnt := 0;
i := GetAdaptersInfo(nil,@cnt);
if i = ERROR_BUFFER_OVERFLOW then
begin
getmem(ia,cnt);
fillchar(ia^,sizeof(ia^),#0);
i := GetAdaptersInfo(ia,@cnt);
if i <> 0 then die(format('Function GetAdaptersInfo returned error (%d).',[i]));
end;
setlength(ial, cnt div (sizeof(ia^)-5));
// i := 0;
Card.Text := string(pchar(@ia^.Description));
end;
end.
No i to u mnie działa, ale mam prośbę do was żebyście mi to sprawdzili czy to u was też dobrze działa bo na przykład jak ktoś ma więcej kart to czy będzie pokazywać tą co się aktualnie łączy z siecią (internetem).