AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Win32/Win64 API (native code) Delphi Partition auslesen mit DeviceIoControl und IOCTL_DISK_GET_PARTITION_INFO_EX
Thema durchsuchen
Ansicht
Themen-Optionen

Partition auslesen mit DeviceIoControl und IOCTL_DISK_GET_PARTITION_INFO_EX

Ein Thema von Captnemo · begonnen am 8. Okt 2015 · letzter Beitrag vom 11. Okt 2015
Antwort Antwort
Benutzerbild von Captnemo
Captnemo

Registriert seit: 27. Jan 2003
Ort: Bodenwerder
1.126 Beiträge
 
Delphi XE4 Architect
 
#1

AW: Partition auslesen mit DeviceIoControl und IOCTL_DISK_GET_PARTITION_INFO_EX

  Alt 8. Okt 2015, 12:02
Bin je wieder einen Schritt weiter.
PartitionCount liefert bei MBR-Partitionen immer ein vielfaches von 4 zurück. Das erklärt schon mal, warum also immer 4 dort steht.

Also muss man anders an die Information, welche Partitionen denn nun wirklich exstieren.
Dabei hilft DRIVE_LAYOUT_INFORMATION_EX.PartitionInfoEx[p].Mbr.PartitionType, worin im Falle von MBR diese Information gefunden werden kann.

Delphi-Quellcode:
Const
    PARTITION_ENTRY_UNUSED = $00;
    PARTITION_EXTENDED = $05;
    PARTITION_FAT_12 = $01;
    PARTITION_FAT_16 = $04;
    PARTITION_FAT32 = $0B;
    PARTITION_IFS = $07;
    PARTITION_LDM = $42;
    PARTITION_NTFT = $80;
    VALID_NTFT = $C0;

.
.
.

            if Layout.PartitionInfoEx[p].PartitionStyle=PARTITION_STYLE_MBR then
            begin
              case Layout.PartitionInfoEx[p].Mbr.PartitionType of
                PARTITION_ENTRY_UNUSED: mmo1.lines.Add(' Part-Style : PARTITION_ENTRY_UNUSED');
                PARTITION_EXTENDED: mmo1.lines.Add(' Part-Style : PARTITION_EXTENDED');
                PARTITION_FAT_12: mmo1.lines.Add(' Part-Style : PARTITION_FAT_12');
                PARTITION_FAT_16: mmo1.lines.Add(' Part-Style : PARTITION_FAT_16');
                PARTITION_FAT32: mmo1.lines.Add(' Part-Style : PARTITION_FAT32');
                PARTITION_IFS: mmo1.lines.Add(' Part-Style : PARTITION_IFS');
                PARTITION_LDM: mmo1.lines.Add(' Part-Style : PARTITION_LDM');
                PARTITION_NTFT: mmo1.lines.Add(' Part-Style : PARTITION_NTFT');
                VALID_NTFT: mmo1.lines.Add(' Part-Style : VALID_NTFT');
              else
                mmo1.lines.Add(' Part-Style : Unbekannt');
              end;
            end;
das Ergebnis schaut jetzt so aus:
Code:
1. Festplatte = 4 Partitionen
  1. Partition:
    Part-Typ  : MBR
    Part-Style : PARTITION_IFS
    PartitionNr: 1
    StartSektor: 1048576
    Länge     : 367001600
    Größe     : 350,00 MB
  2. Partition:
    Part-Typ  : MBR
    Part-Style : PARTITION_ENTRY_UNUSED
    PartitionNr: 0
    StartSektor: 0
    Länge     : 0
    Größe     : 0,00 Byte
  3. Partition:
    PartitionNr: 0
    StartSektor: 2
    Länge     : 3087428650860807
    Größe     : 2,74 PB
  4. Partition:
    Part-Typ  : MBR
    Part-Style : PARTITION_ENTRY_UNUSED
    PartitionNr: 0
    StartSektor: 0
    Länge     : 0
    Größe     : 0,00 Byte
2. Festplatte = 4 Partitionen
  1. Partition:
    Part-Typ  : MBR
    Part-Style : PARTITION_IFS
    PartitionNr: 1
    StartSektor: 1048576
    Länge     : 1000202043392
    Größe     : 931,51 GB
  2. Partition:
    PartitionNr: 3429319
    StartSektor: 2421637
    Länge     : 4213862
    Größe     : 4,02 MB
  3. Partition:
    Part-Typ  : MBR
    Part-Style : Unbekannt
    PartitionNr: 1781809
    StartSektor: 0
    Länge     : 0
    Größe     : 0,00 Byte
  4. Partition:
    PartitionNr: 3654587
    StartSektor: 2787577
    Länge     : 2128090
    Größe     : 2,03 MB
3. Festplatte = 1 Partitionen
  1. Partition:
    Part-Typ  : MBR
    Part-Style : PARTITION_ENTRY_UNUSED
    PartitionNr: 0
    StartSektor: 0
    Länge     : 0
    Größe     : 0,00 Byte
4. Festplatte = 4 Partitionen
  1. Partition:
    Part-Typ  : MBR
    Part-Style : PARTITION_IFS
    PartitionNr: 1
    StartSektor: 1048576
    Länge     : 1073738678272
    Größe     : 1.000,00 GB
  2. Partition:
    PartitionNr: 8
    StartSektor: 0
    Länge     : -6047066961440
    Größe     : -6.047.066.961.440,00 Byte
  3. Partition:
    Part-Typ  : MBR
    Part-Style : PARTITION_ENTRY_UNUSED
    PartitionNr: 1
    StartSektor: 0
    Länge     : 0
    Größe     : 0,00 Byte
  4. Partition:
    Part-Typ  : MBR
    Part-Style : PARTITION_ENTRY_UNUSED
    PartitionNr: 0
    StartSektor: 0
    Länge     : 0
    Größe     : 0,00 Byte
Bis auf die Tatsache, dass mir bei meiner 1. Platte die 2. Partition als UNUSED angezeigt wird, was definitiv nicht so ist, kann ich damit schon mal arbeiten. Da die anderen Platten nur eine Partition haben, muss ich mir erst mal noch eine weitere einbauen, um mal zu testen, was bei mehreren Partitionen so passiert.
Dieter
9 von 10 Stimmen in meinem Kopf sagen ich bin nicht verrückt. Die 10. summt dazu die Melodie von Supermario Bros.
MfG Captnemo

Geändert von Captnemo ( 8. Okt 2015 um 12:05 Uhr)
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 23:24 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