OkMuOnline


NowaHosting


AlphaServers


Resultados 1 a 1 de 1
  1. #1
    Developer Delphi DJ Thanatus's Avatar



    Data de Ingresso
    Jan 2023
    Localização
    Santa Catarina
    Posts
    5
    Thanks Thanks Given 
    2
    Thanks Thanks Received 
    35
    Thanked in
    5 Posts
    Mentioned
    0 Post(s)
    País
    Brazil

    Dicas Delphi - Detectando o MAC do PC

    Detectando o MAC do PC

    Função que retorna o MAC do computador.

    Código:
    function GetMacId(): String;
    var
    Lib: Cardinal;
    Func: function(GUID: PGUID): Longint; stdcall;
    GUID1, GUID2: TGUID;
    begin
    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;

    Exemplos de Uso:
    Código:
    ShowMessage(GetMacId());
    Edit1.Text:=GetMacId();

  2. The Following User Says Thank You to DJ Thanatus For This Useful Post:


Tags para este Tópico

Permissões de Postagem

  • Você não pode iniciar novos tópicos
  • You may not post Resposta(s)
  • Você não pode enviar anexos
  • Você não pode editar suas mensagens
  •