Einzelnen Beitrag anzeigen

Benutzerbild von Luckie
Luckie

Registriert seit: 29. Mai 2002
37.621 Beiträge
 
Delphi 2006 Professional
 
#1

Bitmasken prüfen

  Alt 19. Mär 2006, 23:50
Ich habe folgende Bitmasken:
Delphi-Quellcode:
const
  SV_TYPE_WORKSTATION = $00000001; // A LAN Manager workstation
  SV_TYPE_SERVER = $00000002; // A LAN Manager server
  SV_TYPE_SQLSERVER = $00000004; // Any server running with Microsoft SQL Server
  SV_TYPE_DOMAIN_CTRL = $00000008; // Primary domain controller
  SV_TYPE_DOMAIN_BAKCTRL = $00000010; // Backup domain controller
  SV_TYPE_TIME_SOURCE = $00000020; // Server running the Timesource service
  SV_TYPE_AFP = $00000040; // Apple File Protocol server
  SV_TYPE_NOVELL = $00000080; // Novell server
  SV_TYPE_DOMAIN_MEMBER = $00000100; // LAN Manager 2.x domain member
  SV_TYPE_PRINTQ_SERVER = $00000200; // Server sharing print queue
  SV_TYPE_DIALIN_SERVER = $00000400; // Server running dial-in service
  SV_TYPE_XENIX_SERVER = $00000800; // Xenix server
  SV_TYPE_SERVER_UNIX = SV_TYPE_XENIX_SERVER; //
  SV_TYPE_NT = $00001000; // Windows Server 2003, Windows XP, Windows 2000, or Windows NT
  SV_TYPE_WFW = $00002000; // Server running Windows for Workgroups
  SV_TYPE_SERVER_MFPN = $00004000; // Microsoft File and Print for NetWare
  SV_TYPE_SERVER_NT = $00008000; // Windows Server 2003, Windows 2000 server, or Windows NT server that is not a domain controller
  SV_TYPE_POTENTIAL_BROWSER = $00010000; // Server that can run the browser service
  SV_TYPE_BACKUP_BROWSER = $00020000; // Server running a browser service as backup
  SV_TYPE_MASTER_BROWSER = $00040000; // Server running the master browser service
  SV_TYPE_DOMAIN_MASTER = $00080000; // Server running the domain master browser
  SV_TYPE_SERVER_OSF = $00100000; //
  SV_TYPE_SERVER_VMS = $00200000;
  SV_TYPE_WINDOWS = $00400000; // Windows95 and above
  SV_TYPE_DFS = $00800000; // Root of a DFS tree
  SV_TYPE_CLUSTER_NT = $01000000; // NT Cluster
  SV_TYPE_TERMINALSERVER = $02000000; // Terminal Server(Hydra)
  SV_TYPE_CLUSTER_VS_NT = $04000000; // NT Cluster Virtual Server Name
  SV_TYPE_DCE = $10000000; // IBM DSS (Directory and Security Services) or equivalent
  SV_TYPE_ALTERNATE_XPORT = $20000000; // return list for alternate transport
  SV_TYPE_LOCAL_LIST_ONLY = $40000000; // Return local list only
  SV_TYPE_DOMAIN_ENUM = DWORD($80000000); // Primary domain
  SV_TYPE_ALL = DWORD($FFFFFFFF); // handy for NetServerEnum2
Wie kann ich die jetzt am cleversten zerlegen? Ich habe keine Lust 33 if-Abfragen à la:
Delphi-Quellcode:
function ServerTypeToStringArray(svType: DWORD): TStringDynArray;
begin
  if svType and SV_TYPE_WORKSTATION = 0 then
  begin
    setlength(result, length(result) + 1);
    result[High(result)] := 'Lan Manager Workstation';
  end;
  if svType and SV_TYPE_SERVER = 0 then
  begin
    setlength(result, length(result) + 1);
    result[High(result)] := 'LAN Manager server';
  end;
end;
zu schreiben.
Michael
Ein Teil meines Codes würde euch verunsichern.
  Mit Zitat antworten Zitat