Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

MAC adress

90 views
Skip to first unread message

Andreas Junker

unread,
Dec 3, 1999, 3:00:00 AM12/3/99
to
Hi,

can anybody tell me, how do get the MAC - adress of the network-adapter
(in Delphi or C++) or any other local uniqua number of the computer ?

Thanks


Zorallin

unread,
Dec 3, 1999, 3:00:00 AM12/3/99
to
Try searching Altavista with "MAC Address".
http://www.torry.ru/ has something too.
There are samples out there (in C & Delphi).

HTH

Andreas Junker <andreas...@t-online.de> wrote in message
news:3847998A...@t-online.de...

Frank Reinhardt

unread,
Dec 3, 1999, 3:00:00 AM12/3/99
to
Andreas Junker schrieb:

> can anybody tell me, how do get the MAC - adress of the network-adapter
> (in Delphi or C++) or any other local uniqua number of the computer ?

Hello Andreas, try the following code:

Uses
NB30, SysUtils;

Type
TMACAddress = Array[0..5] Of Byte;
PMACAddress = ^TMACAddress;

Function ResetLANAdapter(AdapterNumber: Byte): Byte;
Var
tmpNCB: PNCB;
Begin
New(tmpNCB);
ZeroMemory(tmpNCB, SizeOf(TNCB));
Try
With tmpNCB^ Do
Begin
ncb_lana_num := Char(AdapterNumber); // Set AdapterNumber
ncb_command := Char(NCBRESET); // Set command RESET
NetBios(tmpNCB);
Result := Byte(ncb_cmd_cplt);
End;
Finally
Dispose(tmpNCB);
End;
End;

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;

Philip Ma

unread,
Dec 3, 1999, 3:00:00 AM12/3/99
to
Frank Reinhardt <rein...@hiserv.de> wrote:
>Function ResetLANAdapter(AdapterNumber: Byte): Byte;

>Function GetMACAddress(AdapterNumber: Byte; MACAddress: PMACAddress): Byte;
>Function GetMACAddressAsString(AdapterNumber: Byte): String;

Frank,

Nice to see you here again!

You offer a great example on get MAC address, there is a probelm on
the above code: some net cards' driver offer a function to change MAC
address.

My net card is "D-Link DE-220". You can buy it under US$20. All D-Link
card (not only D-Link) can easily change MAC address by following
steps:
1. Start control panel.
2. Double click the "NetWork" icon.
3. Select the Adapter tab.
4. Double click the adapter in the list.
5. Change any MAC address you want.
6. Confirm any further promt and restart the computer.
7. Try GetMACAddressAsString again, you will get new MAC address.
(you can also try Win/NT's (maybe Win/98 has this also) command
"ipconfig /all")

Some softwares are not cheated by the above setting. I don't know how
they do it, is anyone know?


Philip Ma

Frank Reinhardt

unread,
Dec 3, 1999, 3:00:00 AM12/3/99
to
Philip Ma schrieb:

> You offer a great example on get MAC address, there is a probelm on
> the above code: some net cards' driver offer a function to change MAC
> address.

Hi Philip,

maybe it愀 possible to change MAC-address of some network-cards, but the only
thing, Andreas wanted to know is how to get it.
IMO MAC-address is no relyable way to protect software from being copied
illegal, because the user could change his card, perhaps it愀 damaged or
whatever else. You can愒 expect of a user to call for a new registration key,
everytime he is replacing some components of his machine.

YMMV, but after careful consideration, I think you will change your mind.

Frank

P.S.: Sorry Phillip, still no idea for your problem
news://forums.inprise.com/383f25c8.20060936%40forums.inprise.com


Paul Loht

unread,
Dec 3, 1999, 3:00:00 AM12/3/99
to

>> Some softwares are not cheated by the above setting. I don't know how
they do it, is anyone know? <<

You bind an Ipx socket to it.

--
Paul Loht
-Real men do it with blocking sockets.

Philip Ma

unread,
Dec 5, 1999, 3:00:00 AM12/5/99
to
"Paul Loht" <pl...@adavi.com> wrote:
>
>>> Some softwares are not cheated by the above setting. I don't know how
>they do it, is anyone know? <<
>
>You bind an Ipx socket to it.
>

Paul,

Could you show me how to do it with a simple example/description?

Thanks!


Philip Ma

Cyco

unread,
Dec 6, 1999, 3:00:00 AM12/6/99
to
try createguid for a unique number

Andreas Junker <andreas...@t-online.de> wrote in message
news:3847998A...@t-online.de...
> Hi,
>
> can anybody tell me, how do get the MAC - adress of the network-adapter
> (in Delphi or C++) or any other local uniqua number of the computer ?
>
> Thanks
>

Peter Coe

unread,
Dec 27, 1999, 3:00:00 AM12/27/99
to
Disk Drive Serial Numbers are unique also, Basically the way I manage it is I
require the the user to register the the program on line during
installation/re-installation, the setup program installs the application to the
desired drive, and then records the drives serial number which is passed to a
registration database, the registration database has three fields,
Registered_To,HD_SN,Registered_SN located on my server, each time the program is
started it request it fires up a Internet connection and request permission to
run from the registration database, by passing the three fields numbers. If the
user ever want's to change the HD or machine it is running on they can do it by
reinstalling. Re-Installation updates the HD_SN field to reflect the new machine
or HD the application is located on this scheam works great and tend to keep
them honest. Just keep in mind that you will never stop a hacker from modifying
the code to bypass registration authentication, but you can slow em down enough
to make it not worth their time.

Pete Coe
http://www.delphipantheon.com


0 new messages