Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 936259
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T21:17:12+00:00 2026-05-15T21:17:12+00:00

Possible Duplicates: Getting Machine’s MAC Address — Good Solution? How do I get the

  • 0

Possible Duplicates:
Getting Machine’s MAC Address — Good Solution?
How do I get the MAC address of a network card using Delphi?

I am using MAC address as hardware id for protection(ofcourse I have encrypted this data)
I am using below code to get MAC address on user computer

function MacAddress: string;
var
Lib: Cardinal;
Func: function(GUID: PGUID): Longint; stdcall;
GUID1, GUID2: TGUID;
begin
Result := '';
Lib := LoadLibrary('rpcrt4.dll');
if Lib <> 0 then
begin
   @Func := GetProcAddress(Lib, 'UuidCreateSequential');
   if Assigned(Func) then
   begin
     if (Func(@GUID1) = 0) and
        (Func(@GUID2) = 0) and
        (GUID1.D4[2] = GUID2.D4[2]) and
        (GUID1.D4[3] = GUID2.D4[3]) and
        (GUID1.D4[4] = GUID2.D4[4]) and
        (GUID1.D4[5] = GUID2.D4[5]) and
        (GUID1.D4[6] = GUID2.D4[6]) and
        (GUID1.D4[7] = GUID2.D4[7]) then
     begin
       Result :=
         IntToHex(GUID1.D4[2], 2) + '-' +
         IntToHex(GUID1.D4[3], 2) + '-' +
         IntToHex(GUID1.D4[4], 2) + '-' +
         IntToHex(GUID1.D4[5], 2) + '-' +
         IntToHex(GUID1.D4[6], 2) + '-' +
         IntToHex(GUID1.D4[7], 2);
     end;
   end;
end;
end;

above code works perfectly on windows XP
but its giving different values in windows7 ,the value changing every time after computer resratred 🙁
is there any chance of getting MAC address thats constant (unless user changed his MAC address)
or is there any good code which retrvies constant data on all OS ?

thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T21:17:13+00:00Added an answer on May 15, 2026 at 9:17 pm

    @steve0, to retrieve the mac address of an Network Adapter you can use the WMI and the Win32_NetworkAdapterConfiguration Class and check the MACAddress property.

    Check this code:

    program WMI_MAC;
    
    {$APPTYPE CONSOLE}
    
    
    uses
      SysUtils
      ,ActiveX
      ,ComObj
      ,Variants;
    
     function VarToStrNil(Value:Variant):string;  //Dummy function to onvert an variant value to string
     begin
       if VarIsNull(Value) then
        Result:=''
       else
        Result:=VarToStr(Value);
     end;
    
    
    Procedure GetMacAddress;
    var
      objWMIService : OLEVariant;
      colItems      : OLEVariant;
      colItem       : OLEVariant;
      oEnum         : IEnumvariant;
      iValue        : LongWord;
      wmiHost, root, wmiClass: string;
    
      function GetWMIObject(const objectName: String): IDispatch;
      var
        chEaten: Integer;
        BindCtx: IBindCtx;//for access to a bind context
        Moniker: IMoniker;//Enables you to use a moniker object
      begin
        OleCheck(CreateBindCtx(0, bindCtx));
        OleCheck(MkParseDisplayName(BindCtx, StringToOleStr(objectName), chEaten, Moniker));//Converts a string into a moniker that identifies the object named by the string
        OleCheck(Moniker.BindToObject(BindCtx, nil, IDispatch, Result));//Binds to the specified object
      end;
    
    begin
      wmiHost       := '.';
      root          := 'root\CIMV2';
      wmiClass      := 'Win32_NetworkAdapterConfiguration';
      objWMIService := GetWMIObject(Format('winmgmts:\\%s\%s',[wmiHost,root]));
      colItems      := objWMIService.ExecQuery(Format('SELECT * FROM %s',[wmiClass]),'WQL',0);
      oEnum         := IUnknown(colItems._NewEnum) as IEnumVariant;
      while oEnum.Next(1, colItem, iValue) = 0 do
      //if VarToStrNil(colItem.MACAddress)<>'' then //uncomment if you only want list the interfaces with mac adress
      //if colItem.IPEnabled then  // uncomment if you only want list the active interfaces
      begin
        WriteLn('Card Description '+VarToStrNil(colItem.Caption));
        WriteLn('MACAddress       '+VarToStrNil(colItem.MACAddress));
      end;
    end;
    
    begin
     try
        CoInitialize(nil);
        try         
          GetMacAddress;
          Readln;
        finally
        CoUninitialize;
        end;
     except
        on E:Exception do
        Begin
            Writeln(E.Classname, ': ', E.Message);
            Readln;
        End;
      end;
    end.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 537k
  • Answers 537k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer optimal would be IMHO the the following: have an object… May 17, 2026 at 1:48 am
  • Editorial Team
    Editorial Team added an answer They might not be public in the strictest sense of… May 17, 2026 at 1:48 am
  • Editorial Team
    Editorial Team added an answer document.documentElement.scrollHeight I believe. For viewport it's window.innerHeight for modern browsers.… May 17, 2026 at 1:48 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Possible Duplicates: Getting the path of the current assembly C#: How do I get
Possible Duplicates: Advice on using ASP.net WebForms or MVC How to decide which is
Possible Duplicates: What’s the best way to build a string of delimited items in
Possible Duplicate: Problem getting Facebook pictures via iOS How to get user's facebook profile
Is there a way of getting dpkg, apt-get or aptitude to produce a list
Possible Duplicates: How to obtain anchor part of URL after # in php Is
I found a bunch of possible duplicates around this but none really seemed to
Possible Duplicates: What is the best way to learn Ruby? Explain Iterator Syntax on
Possible Duplicate: Why am I getting Undefined index from my PHP? $pattern2 = /([A-Za-z0-9\.\-\_\!\#\$\%\&\'\*\+\/\=\?\^\`\{\|\}]+)\@([A-Za-z0-9.-_]+)(\.[A-Za-z]{2,5})/;
Possible Duplicate: Why am I getting an “Out of memory” error with Perl's XML::Simple?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.