Board index » delphi » Different declarations for getting MAC Address on Win 98, NT4, and 2000

Different declarations for getting MAC Address on Win 98, NT4, and 2000

I am developing an application that is required to work on all
platforms of windows in Delphi 3.  The application uses the MAC
Address of the computer to uniquely identify the computer.  I am using
the CoCreateGuid function in the ole32.dll.  This works fine for all
platforms of windows except win 2000 where they changed it for
security reasons.  I have discovered that i can use the
UuidCreateSequential function in the rpcrt4.dll to do this on the 2000
OS's, however my problem is that i need the one application to run on
all platforms and when i run the app on win 98 or NT4 machines i get
the following error because the rpcrt4.dll is an old version.

"The procedure entry point UuidCreateSequential could not be found in
the dynamic link library rpcrt4.dll"

And the application then closes and so it wont work. I do not want to
update the versions of the rpcrt4.dll on the older operating systems,
as this will be used on a large number of computers.  I am wondering
if there is some way of controlling which declaration is used on
different operating systems.  I am declaring the 2 functions required
for this task on all operating systems in the following manner.

{function for win 98, NT4 for getting the MAC Address}
function CoCreateGuid(var guid: TGUID): HResult; stdcall; far external
'ole32.dll';
{Function for win 2000 for getting the Mac Address}
function UuidCreateSequential(var guid: TGUID): HResult; stdcall; far
external 'rpcrt4.dll';

If anyone could help it would be greatly appreciated.

thanks

Matt

 

Re:Different declarations for getting MAC Address on Win 98, NT4, and 2000


You can also use NetBios to get MAC addresses. Example:

uses
  Nb30;

procedure TForm1.FormCreate(Sender: TObject);
const
  MachineName = '*               ';
var
  NCB: TNCB;
  Enum: TLanaEnum;
  i: Integer;
  Adapter: record
    adapt: TAdapterStatus;
    namebuf: array [0..29] of TNameBuffer;
  end;
begin
  ListBox1.Items.Clear;
  FillChar(NCB, SizeOf(NCB), #0);
  NCB.ncb_command := Char(NCBENUM);
  NCB.ncb_buffer := Pointer(@Enum);
  NCB.ncb_length := SizeOf(Enum);
  if NetBios(@NCB) = Char(NRC_GOODRET) then
  begin
    for i := 0 to Byte(Enum.Length) - 1 do
    begin
      FillChar(NCB, SizeOf(NCB), #0);
      NCB.ncb_command := Char(NCBRESET);
      NCB.ncb_lana_num := Enum.lana[i];
      if NetBios(@NCB) = Char(NRC_GOODRET) then
      begin
        FillChar(NCB, SizeOf(NCB), #0);
        NCB.ncb_command := Char(NCBASTAT);
        NCB.ncb_lana_num := Enum.lana[i];
        Move(MachineName[1], NCB.ncb_callname, SizeOf(NCB.ncb_callname));
        NCB.ncb_buffer := PChar(@Adapter);
        NCB.ncb_length := SizeOf(Adapter);
        if NetBios(@NCB) = Char(NRC_GOODRET) then
          ListBox1.Items.Add(Format('%.2x-%.2x-%.2x-%.2x-%.2x-%.2x', [
            Integer(Adapter.adapt.adapter_address[0]),
Integer(Adapter.adapt.adapter_address[1]),
            Integer(Adapter.adapt.adapter_address[2]),
Integer(Adapter.adapt.adapter_address[3]),
            Integer(Adapter.adapt.adapter_address[4]),
Integer(Adapter.adapt.adapter_address[5])]));
      end;
    end;
  end;
end;

Quote
"Matt Lavery" <matt_lav...@hotmail.com> wrote in message

news:4b8e3a8d.0109131645.5894d24@posting.google.com...
Quote
> I am developing an application that is required to work on all
> platforms of windows in Delphi 3.  The application uses the MAC
> Address of the computer to uniquely identify the computer.  I am using
> the CoCreateGuid function in the ole32.dll.  This works fine for all
> platforms of windows except win 2000 where they changed it for
> security reasons.  I have discovered that i can use the
> UuidCreateSequential function in the rpcrt4.dll to do this on the 2000
> OS's, however my problem is that i need the one application to run on
> all platforms and when i run the app on win 98 or NT4 machines i get
> the following error because the rpcrt4.dll is an old version.

> "The procedure entry point UuidCreateSequential could not be found in
> the dynamic link library rpcrt4.dll"

> And the application then closes and so it wont work. I do not want to
> update the versions of the rpcrt4.dll on the older operating systems,
> as this will be used on a large number of computers.  I am wondering
> if there is some way of controlling which declaration is used on
> different operating systems.  I am declaring the 2 functions required
> for this task on all operating systems in the following manner.

> {function for win 98, NT4 for getting the MAC Address}
> function CoCreateGuid(var guid: TGUID): HResult; stdcall; far external
> 'ole32.dll';
> {Function for win 2000 for getting the Mac Address}
> function UuidCreateSequential(var guid: TGUID): HResult; stdcall; far
> external 'rpcrt4.dll';

> If anyone could help it would be greatly appreciated.

> thanks

> Matt

Other Threads