Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "Сети";
Текущий архив: 2005.03.27;
Скачать: [xml.tar.bz2];

Вниз

physical adress cетевухи?   Найти похожие ветки 

 
Studentas   (2005-01-13 12:40) [0]

как узнать physical adress cетевухи?
во всех версиях Виндоw?


 
Verg ©   (2005-01-13 13:38) [1]

Начиная с 98-ой
Функциями GetAdaptersInfo или GetIfTable из iphlpapi.dll


 
XmeD   (2005-01-24 17:15) [2]

{
*** Get MAC Adress ***
*** by Filip Skalka, fip@post.cz ***
*** September 2002 ***

*** Edition 2004 ***
   by XmeD
}

unit MACAdress;
interface
uses classes, ShellAPI, WinSock, Windows;

function GetMACAdresses(const Adresses:TStringList;const MachineName:string=""):integer;
function GetMACAdress(const MachineName:string=""):string;
function GetComputerNetName: string;
function GetLocalIP: String;
function IsNetConnection: Boolean;

implementation
uses NB30,sysutils;

type
ENetBIOSError=class(Exception);

function NetBiosCheck(const b:char):char;
begin
if b<>chr(NRC_GOODRET) then raise ENetBIOSError.create("NetBios error"#13#10"Error code "+inttostr(ord(b)));
result:=b;
end;

function AdapterToString(const Adapter:PAdapterStatus):string;
begin
with Adapter^ do Result :=Format("%2.2x-%2.2x-%2.2x-%2.2x-%2.2x-%2.2x",[Integer(adapter_address[0]),Integer(adapter_address[1]),Integer(adapter_ address[2]), Integer(adapter_address[3]),Integer(adapter_address[4]), Integer(adapter_address[5])]);
end;

function GetLocalIP: String;
const WSVer = $101;
var
 wsaData: TWSAData;
 P: PHostEnt;
 Buf: array [0..127] of Char;
begin
 Result := "";
 if WSAStartup(WSVer, wsaData) = 0 then begin
   if GetHostName(@Buf, 128) = 0 then begin
     P := GetHostByName(@Buf);
     if P <> nil then Result := iNet_ntoa(PInAddr(p^.h_addr_list^)^);
   end;
   WSACleanup;
 end;
end;

function GetComputerNetName: string;
var
   buffer: array[0..255] of char;
   size: dword;
begin
   size := 256;
   if GetComputerName(buffer, size) then
       Result := buffer
   else
       Result := ""
end;

function IsNetConnection: Boolean;
begin
 if GetSystemMetrics(SM_NETWORK) and $01 = $01 then
   result := True
 else
   result := False;
end;

procedure MachineNameToAdapter(Name:string;var AdapterName:array of char);
begin
if Name="" then Name:="*" else Name:=ansiuppercase(Name);
Name:=Name+StringOfChar(" ",length(AdapterName)-Length(Name));
move(Name[1],AdapterName[0],length(AdapterName));
end;

function GetMACAdresses(const Adresses:TStringList;const MachineName:string=""):integer;
var i:integer;
   NCB: PNCB;
   Adapter:PAdapterStatus;
   Lenum:PLanaEnum;
   RetCode:char;
begin
Adresses.clear;

New(NCB);
New(Adapter);
New(Lenum);
try
 Fillchar(NCB^,SizeOf(TNCB),0);
 fillchar(Lenum^,SizeOf(TLanaEnum),0);
 NCB.ncb_command:=chr(NCBENUM);
 NCB.ncb_buffer:=Pointer(Lenum);
 NCB.ncb_length:=SizeOf(Lenum);
 NetBiosCheck(Netbios(NCB));
 result:=ord(Lenum.Length);

 for i:=0 to result-1 do
 begin
  Fillchar(NCB^,SizeOf(TNCB),0);
  Ncb.ncb_command:=chr(NCBRESET);
  Ncb.ncb_lana_num:=lenum.lana[i];
  NetBiosCheck(Netbios(Ncb));

  FillChar(NCB^,SizeOf(TNCB),0);
  FillChar(Adapter^,SizeOf(TAdapterStatus),0);

  Ncb.ncb_command:=chr(NCBASTAT);
  Ncb.ncb_lana_num:=lenum.lana[i];
  MachineNameToAdapter(MachineName,Ncb.ncb_callname);
  Ncb.ncb_buffer:=Pointer(Adapter);
  Ncb.ncb_length:=SizeOf(TAdapterStatus);
  RetCode:=Netbios(NCB);
  if RetCode in [chr(NRC_GOODRET),chr(NRC_INCOMP)] then Adresses.add(AdapterToString(Adapter));
 end;
finally
 Dispose(NCB);
 Dispose(Adapter);
 Dispose(Lenum);
end;
end;

function GetMACAdress(const MachineName:string=""):string;
var stringlist:tstringlist;
begin
stringlist:=tstringlist.create;
try
 if GetMACAdresses(stringlist,MachineName)=0 then result:="" else result:=stringlist[0];
finally
 stringlist.destroy;
end;
end;

end.



Страницы: 1 вся ветка

Форум: "Сети";
Текущий архив: 2005.03.27;
Скачать: [xml.tar.bz2];

Наверх




Память: 0.46 MB
Время: 0.04 c
14-1110284287
Novice__
2005-03-08 15:18
2005.03.27
Беспроводная сеть


1-1110964851
PVOzerski
2005-03-16 12:20
2005.03.27
Как бы управлять порядком уничтожения компонентов?


8-1100693767
Kirill
2004-11-17 15:16
2005.03.27
Формат PNG в стандартный TImage


8-1102414706
dr Tr0jan
2004-12-07 13:18
2005.03.27
Не могу снять скриншот


1-1110810294
Manfred8
2005-03-14 17:24
2005.03.27
Какую кодировку использует Дельфя для хранения данных в dfm?





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский