[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


Delphi get in use mac address

Posted on 2011-10-13
Medium Priority
Last Modified: 2012-05-12
hello friends i am picked various commands for pick mac address in delphi and not picked one good, i am need pick the active network mac address, in my pc i am have virtualbox and more than one mac address and when i run program in delphi pick another mac address not pick the mac i am using.
Please help me
Question by:kidd12
  • 2
LVL 19

Expert Comment

ID: 36961067
Have you already tried this???

Get NIC MAC Address
LVL 19

Accepted Solution

Thommy earned 2000 total points
ID: 36961075
Another way to retrieve mac addresses of all interfaces...


Expert Comment

ID: 36967783
First simplest way to get MAC address is using windows API from Ole32.dll.
This will get you the first MAC address in case of multiple mac addresses(fro multiple cards).

function CoCreateGuid(var guid: TGUID): HResult; stdcall; far external 'ole32.dll';

function Get_MACAddress: string;
  g: TGUID;
  i: Byte;
  Result := '';
  for i := 2 to 7 do
    Result := Result + IntToHex(g.D4[i], 2);

Open in new window

LVL 13

Expert Comment

ID: 36970160

"The CoCreateGuid function calls the RPC function UuidCreate"
"For security reasons, UuidCreate was modified so that it no longer uses a machine's MAC address to generate UUIDs."

The simplest solution if you already have JCL (http://wiki.delphi-jedi.org/index.php?title=JEDI_Code_Library) installed is to use GetMacAddresses() found in JclSysInfo.pas.

The reason I prefer this method is because it incorporates the other methods shown here as well as a few others just in case on method fails.

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question