bobsacamano 0 Newbie Poster

I have a problem using the GetAdaptersInfo funtion on Delphi 2010 on Windows 7. The following code works fine and returns the adapter names/descriptions to the memo when compiled using Delphi 2007 on Windows Vista. When compiled using Delphi 2010 on Windows 7 it returns blanks or garbage (output below). Are there any compatibility problems using GetAdaptersInfo on Delphi 2010 or Windows 7? Heres some sample code that replicates the problem and the output for it, thanks for any help.

Code:

unit SDIMAIN;

interface

uses Windows, Classes, Graphics, Forms, Controls, Menus,
  Dialogs, StdCtrls, Buttons, ExtCtrls, ComCtrls, ImgList, StdActns,
  ActnList, ToolWin;

type
  TSDIAppForm = class(TForm)
    StatusBar: TStatusBar;
    Button1: TButton;
    Memo1: TMemo;

    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  SDIAppForm: TSDIAppForm;

implementation


uses about, IPHlpAPI, IPTypes, SysUtils;

{$R *.dfm}

procedure TSDIAppForm.Button1Click(Sender: TObject);
var
  pAdapterInfo: PIP_ADAPTER_INFO;
  AdapterInfo: IP_ADAPTER_INFO;
  Status: DWORD;
  BufLen: DWORD;
  Buf: String;
  I: integer;
begin
  BufLen := sizeof(AdapterInfo);
  pAdapterInfo := @AdapterInfo;
  Status := GetAdaptersInfo(nil, BufLen);

  pAdapterInfo := AllocMem(BufLen);

  Status := GetAdaptersInfo(pAdapterInfo, BufLen);

   while (pAdapterInfo <> nil) do
     begin
       Memo1.Lines.Add('Description:    ' + pAdapterInfo^.Description);
       Memo1.Lines.Add('Name:           ' + pAdapterInfo^.AdapterName);
       Buf := '';
       for I := 0 to pAdapterInfo^.AddressLength - 1 do
           Buf := Buf + '-' + IntToHex(pAdapterInfo^.Address[I], 2);
       Delete(Buf, 1, 1);
       Memo1.Lines.Add('MAC address:    ' + Buf);
       Memo1.Lines.Add('IP address:     ' + pAdapterInfo^.IpAddressList.IpAddress.S);
       Memo1.Lines.Add('Gateway:        ' + pAdapterInfo^.GatewayList.IpAddress.S);
       Memo1.Lines.Add('DHCP enabled:   ' + IntTOStr(pAdapterInfo^.DhcpEnabled));
       Memo1.Lines.Add('DHCP:           ' + pAdapterInfo^.DhcpServer.IpAddress.S);
       Memo1.Lines.Add('Have WINS:      ' + BoolToStr(pAdapterInfo^.HaveWins));
       Memo1.Lines.Add('Primary WINS:   ' + pAdapterInfo^.PrimaryWinsServer.IpAddress.S);
       Memo1.Lines.Add('Secondary WINS: ' + pAdapterInfo^.SecondaryWinsServer.IpAddress.S);
       pAdapterInfo := pAdapterInfo^.Next;
   end;
end;

end.

Memos output on Delphi 2007, Windows Vista:

Memo1
Description:    D-Link DGE-530T Gigabit Ethernet Adapter (rev.B)
Name:           {236E8044-8BE7-40B5-881A-D693F58A651D}
MAC address:    00-24-01-00-29-22
IP address:     0.0.0.0
Gateway:        0.0.0.0
DHCP enabled:   0
DHCP:           
Have WINS:      0
Primary WINS:   
Secondary WINS: 
Description:    Broadcom NetXtreme 57xx Gigabit Controller
Name:           {C7D7F486-60E1-44A2-BD6B-7CEB92195A97}
MAC address:    00-19-B9-2E-D6-7D
IP address:     129.173.114.21
Gateway:        129.173.112.1
DHCP enabled:   1
DHCP:           129.173.1.100
Have WINS:      0
Primary WINS:   
Secondary WINS: 

Memos output on Delphi 2010, Windows 7:
Memo1
Description:    
Name:           䑻㐹䕆䘵ⵁㄳ㕂㐭䅂ⴶ㍂䔰䈭㘴㘸㠹䐳䔶紶
MAC address:    
IP address:     
Gateway:        
DHCP enabled:   0
DHCP:           
Have WINS:      0
Primary WINS:   䲐뇥ꪗ
Secondary WINS: 㜱⸳㤱⸲1
Description:    㔲⸵㔲⸵㔲⸵㔲5궁搁
Name:           㕻㙅䐲ㄴⴸぃ㈶㐭㘰ⴱ㠹㐵䘭䈰㑃㝆䄱䉃組
MAC address:    
IP address:     
Gateway:        
DHCP enabled:   0
DHCP:           
Have WINS:      0
Primary WINS:   ␀裡巻
Secondary WINS: ⸰0
Description:    
Name:           㥻㘲䔱㐲ⵁ䅃䘸㐭㜳ⴵ㈹㤵㘭䐲䌲㉆䔲㘰組
MAC address:    
IP address:     
Gateway:        
DHCP enabled:   0
DHCP:           
Have WINS:      0
Primary WINS:   
Secondary WINS: