Einzelnen Beitrag anzeigen

S4SH1981

Registriert seit: 13. Jul 2007
59 Beiträge
 
#11

Re: DLL mehrere Strings auslesen

  Alt 19. Mär 2009, 16:53
Also hier die DLL

Delphi-Quellcode:
function GetNetworkAdapter: string;
var
  MibRow: TMibIfRow;
  IntfTable: PMibIfTable;
  Size: DWORD;
  I: Integer;
  Adapter : array[1..5] of string;
begin
  Size := 0;
  If GetIfTable(nil, Size, True) <> ERROR_INSUFFICIENT_BUFFER then Exit;
  IntfTable := AllocMem(Size);
  Try
    If GetIfTable(IntfTable, Size, True) = NO_ERROR then
      For I := 0 to IntfTable^.dwNumEntries -1 do
        begin
          {$R-}
          MibRow := IntfTable.Table[I];
          adapter[1] :=(PChar(@MibRow.bDescr[0]) + ' @ ' + InttoStr(MibRow.dwSpeed div 1000000)+ ' MBit/s');
          adapter[2] :=(PChar(@MibRow.bDescr[1]) + ' @ ' + InttoStr(MibRow.dwSpeed div 1000000)+ ' MBit/s');
          adapter[3] :=(PChar(@MibRow.bDescr[2]) + ' @ ' + InttoStr(MibRow.dwSpeed div 1000000)+ ' MBit/s');
          adapter[4] :=(PChar(@MibRow.bDescr[3]) + ' @ ' + InttoStr(MibRow.dwSpeed div 1000000)+ ' MBit/s');
          adapter[5] :=(PChar(@MibRow.bDescr[4]) + ' @ ' + InttoStr(MibRow.dwSpeed div 1000000)+ ' MBit/s');

          result := (PChar(@MibRow.bDescr[0]) + ' @ ' + InttoStr(MibRow.dwSpeed div 1000000)+ ' MBit/s'
            );
          {$R+}
        end;
  Finally
    FreeMem(IntfTable);
  end;
end;

exports
   GetNetworkAdapter;

begin
end.
und das Programm

Delphi-Quellcode:
function GetNetworkAdapter : string;
external 'C:\Dokumente und Einstellungen\Bettina & Detlef\Desktop\Delphi\11032009\DLL4\GetNetworkAdapters.dll';

{$R *.dfm}


procedure TForm1.Button1Click(Sender: TObject);
var adapter : array of string;
begin
// ComboBox1.Items.Add(getnetworkadapter);
getnetworkadapter;
//combobox1.Items.add(adapter[1]);

end;
  Mit Zitat antworten Zitat