Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Library: Windows API / MS.NET Framework API (https://www.delphipraxis.net/20-library-windows-api-ms-net-framework-api/)
-   -   Delphi Quotas unter Windows 2000+ auslesen (https://www.delphipraxis.net/6333-quotas-unter-windows-2000-auslesen.html)

Gast 7. Jul 2003 00:30


Quotas unter Windows 2000+ auslesen
 
Liste der Anhänge anzeigen (Anzahl: 1)
Quotas auslesen geht erst ab Windows 2000 aufwärts. Über Windows XP Home habe ich keine Infos. Die Routine benutzt undokumentierte APIs (NT Native API).

Download auch hier: http://assarbad.net/stuff/!export/cquotas.rar
(sonst siehe Attachment).

Der Source ist "Abfall" ich wollte eigentlich mal ein Kommandozeilen-Utility schreiben, mit dem man Quotas setzen kann. Werde ich vielleicht auch noch machen ... aber hier erstmal soweit wie es ist.

Delphi-Quellcode:
begin
  hFile := CreateFileW('\\.\D:', GENERIC_READ or GENERIC_WRITE, FILE_SHARE_WRITE, nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
  if hFile <> INVALID_HANDLE_VALUE then
  try
    fuqi_len := 1 * sizeof(FILE_USER_QUOTA_INFORMATION);
    repeat
      Writeln('Neuer Durchgang');
      if Assigned(fuqi) then
      begin
        FreeMemory(fuqi);
        fuqi_len := fuqi_len * 2;
      end;
      fuqi := GetMemory(fuqi_len);
      ZeroMemory(fuqi, fuqi_len);
      stat := ZwQueryQuotaInformationFile(hFile, @iostat, fuqi, fuqi_len, False, nil, 0, nil, True);
      Writeln(Format('stat = %8.8X', [stat]));

    until (stat = STATUS_NO_MORE_ENTRIES);
    Writeln(Format('iostat.Status   = %8.8X', [iostat.Status]));
    Writeln(Format('stat            = %8.8X', [stat]));
    tempfuqi := fuqi;
    while True do
    begin
      try
        Writeln('-------------------------------------------------------------------------------');
        Writeln(Format('%20d | %20d | %20d', [tempfuqi.QuotaUsed, tempfuqi.QuotaThreshold, tempfuqi.QuotaLimit]));
        if IsValidSID(Pointer(@tempfuqi.Sid)) then
        begin
          Write('-> valid SID: ');
          bufsize := sizeof(buf);
          buf2size := sizeof(buf2);
          if LookupAccountSid(nil, Pointer(@tempfuqi.Sid), @buf, bufsize, @buf2, buf2size, nameuse) then
            Writeln(string(PChar(@buf2)), '\', string(PChar(@buf)));
        end;
        Write('S-', tempfuqi.Sid.Revision, '-', DWORD(tempfuqi.Sid.IdentifierAuthority.Value[5]) + DWORD(tempfuqi.Sid.IdentifierAuthority.Value[4] shl 8) + DWORD(tempfuqi.Sid.IdentifierAuthority.Value[3] shl 16) + DWORD(tempfuqi.Sid.IdentifierAuthority.Value[2] shl 24));
        for i := 0 to (tempfuqi.SidLength - (sizeof(SID) - sizeof(DWORD))) div sizeof(DWORD) - 1 do
        begin
          Write('-', tempfuqi.Sid.SubAuthority[i]);
        end;
        Writeln;
        if tempfuqi.NextEntryOffset <> 0 then
          tempfuqi := PFILE_USER_QUOTA_INFORMATION(PChar(tempfuqi) + tempfuqi.NextEntryOffset)
        else break;
      except
        Writeln('EXCEPTION!!!');
      end;
    end;
    FreeMemory(fuqi);
  finally
    CloseHandle(hFile);
  end;
  Readln;
end.


Alle Zeitangaben in WEZ +1. Es ist jetzt 18:06 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz