Ingin tau cara membaca MAC-Address?
berikut ini petikan kode-nya
berikut ini petikan kode-nya
Type
TMACAddress = Array[0..5] Of Byte;
PMACAddress = ^TMACAddress;
Function GetMACAddress(AdapterNumber: Byte; MACAddress: PMACAddress): Byte;
Var
tmpNCB: PNCB;
AdapterStatus: PAdapterStatus;
begin
New(tmpNCB);
ZeroMemory(tmpNCB, SizeOf(TNCB));
tmpNCB.ncb_length := SizeOf(TAdapterStatus) + 255 SizeOf(TNameBuffer);
GetMem(AdapterStatus, tmpNCB.ncb_length);
Try
With tmpNCB^ Do
Begin
ZeroMemory(MACAddress, SizeOf(TMACAddress));
ncb_buffer := PChar(AdapterStatus);
ncb_callname := ' ' +#0;
ncb_lana_num := Char(AdapterNumber);
ncb_command := Char(NCBASTAT);
NetBios(tmpNCB);
Result := Byte(ncb_cmd_cplt);
If Result = NRC_GOODRET Then
MoveMemory(MACAddress, AdapterStatus, SizeOf(TMACAddress));
End;
Finally
FreeMem(AdapterStatus);
Dispose(tmpNCB);
End;
End;
Function GetMACAddressAsString(AdapterNumber: Byte): String;
Var
tmpMACAddress: TMACAddress;
Begin
If Win32Platform = VER_PLATFORM_WIN32_NT Then
If ResetLANAdapter(AdapterNumber) <> NRC_GOODRET Then
Begin
Result := '??-??-??-??-??-??';
Exit;
End;
If GetMACAddress(AdapterNumber, @tmpMACAddress) = NRC_GOODRET Then
Result := Format('%2.2x-%2.2x-%2.2x-%2.2x-%2.2x-%2.2x',
[tmpMACAddress[0], tmpMACAddress[1], tmpMACAddress[2], tmpMACAddress[3],
tmpMACAddress[4], tmpMACAddress[5]])
Else
Result := '??-??-??-??-??-??';
End;
|
Last Articles
Recent Topic
- PascalTalk #6: (Podcast) Kuliah IT di luar negeri, susah gak sih?
by LuriDarmawan in Tutorial & Community Project more 4 years ago - PascalTalk #5: UX: Research, Design and Engineer
by LuriDarmawan in Tutorial & Community Project more 4 years ago - PascalTalk #4: Obrolan Ringan Seputar IT
by LuriDarmawan in Tutorial & Community Project more 4 years ago - PascalTalk #2: Membuat Sendiri SMART HOME
by LuriDarmawan in Tutorial & Community Project more 4 years ago - PascalTalk #3: RADically Fast and Easy Mobile Apps Development with Delphi
by LuriDarmawan in Tutorial & Community Project more 4 years ago - PascalTalk #1: Pemanfaatan Artificial Intelligence di Masa Covid-19
by LuriDarmawan in Tutorial & Community Project more 4 years ago - Tempat Latihan Posting
by LuriDarmawan in OOT more 5 years ago - Archive
- Looping lagi...
by idhiel in Hal umum tentang Pascal Indonesia more 12 years ago - [ask] koneksi ke ODBC user Dsn saat runtime dengan ado
by halimanh in FireBird more 12 years ago - Validasi menggunakan data tanggal
by mas_kofa in Hal umum tentang Pascal Indonesia more 12 years ago