Einzelnen Beitrag anzeigen

Benutzerbild von negaH
negaH

Registriert seit: 25. Jun 2003
Ort: Thüringen
2.950 Beiträge
 
#5

Re: Bitmasken prüfen

  Alt 20. Mär 2006, 05:46
leicht verbessert

Delphi-Quellcode:
function ServerTypeToStrings(const svType: DWord): TStringDynArray; overload;
const
  cStrings: array[0..31] of String = (
    'LAN Manager workstation', 'LAN Manager server', ...);
var
  I,J: Integer;
begin
  J := 0;
  SetLength(Result, 32);
  for I := 0 to 31 do
    if Odd(svType shr I) then
    begin
      Result[J] := cStrings[I];
      Inc(J);
    end;
  SetLength(Result, J);
end;

function ServerTypeToStrings(const svType: DWord; const Separator: String = ', '): String; overload;
const
  cStrings: array[0..31] of String = (
    'LAN Manager workstation', 'LAN Manager server', ...);
var
  I: Integer;
begin
  Result := '';
  for I := 0 to 31 do
    if Odd(svType shr I) then
      Result := Result + cStrings[I] + Separator;
  SetLength(Result, Length(Result) - Length(Separator));
end;


procedure Test;
begin
  ListBox.Items.Text := ServerTypeToStrings($12345678, #13#10);
end;
  Mit Zitat antworten Zitat