Wie findet man bei Windows die "Harddiskvolume" Nummer heraus?



  • Windows weißT Laufwerksbuchstaben intern
    HarddiskVolume Nummern zu, aber welche Buchstaben bekommen welche Nummern?

    C: = Harddiskvolume1
    😨 = ?
    E: = ?

    Gibt es dafür ein Programm um das auszulesen?



  • Ein Programm? Na Explorer, oder 😕

    Oder meinst du eine API Funktion?
    Dann GetVolumeInformation.



  • Der Explorer zeigt nur C:, 😨 E; etc. an aber keine HarddiskVolume Nummern!

    Zum Programmieren sind meine Kenntnisse bezüglich speziell "Windows Progammierung" nicht ausreichend.
    Desweiteren müßte ich erst nen C++ Compiler installieren,
    was aber momentan keine gute Idee ist, da ich ja gerade dabei bin meine Dokumente und Einstellungen Ordner zu verschieben. -> Registry ist schon zur Hälfte verändert, jetzt fehlt der Rest zum Rebooten.



  • Versuche gerade folgenden Code an gcc anzupassen, habe aber folgendes Problem:

    39 E:\test\harddiskvolume.cpp cannot convert `TCHAR*' to `wchar_t*' for argument `1' to `wchar_t* wcscpy(wchar_t*, const wchar_t*)'
    40 E:\test\harddiskvolume.cpp cannot convert `TCHAR*' to `wchar_t*' for argument `1' to `wchar_t* wcscat(wchar_t*, const wchar_t*)'

    Dummerweise scheint die tchar.h unvollständig zu sein.
    Irgendwelche Vorschläge?

    Hier der Programmcode:

    #define _WIN32_WINNT 0x0501
    #define _UNICODE
    
    #include <windows.h>
    // #include <string.h>   
    // #include <stdlib.h>
    #include <tchar.h>
    #include <iostream>
    
    #define BUFSIZE            MAX_PATH
    #define FILESYSNAMEBUFSIZE MAX_PATH
    
    using namespace std;
    // Process each mount point found here. This makes maintenance easier
    // than doing it in line. The result indicates whether there is
    // another mount point to be scanned.
    
    // This routine prints out the path to a mount point and its target.
    
    BOOL ProcessVolumeMountPoint (HANDLE hPt,
                                  TCHAR *PtBuf, DWORD dwPtBufSize,
                                  TCHAR *Buf)
    {
       BOOL bFlag;             // Boolean result   
       TCHAR Path[BUFSIZE];    // construct a complete path here
       TCHAR Target[BUFSIZE];  // target of mount at mount point
    
       cout << "Volume mount point found is" << PtBuf << endl ;
       // _tprintf (TEXT("\tVolume mount point found is \"%s\"\n"), PtBuf);
    
       // Detect the volume mounted there. Unfortunately, there is no 
       // simple way to map a unique volume name to a DOS drive letter. 
       // One way to do that is to build an associative array, which we 
       // will "leave as an exercise for the student." 
    
       // Build a unique path to the mount point
    
       _tcscpy (Path, Buf);
       _tcscat (Path, PtBuf);
    
       bFlag = GetVolumeNameForVolumeMountPoint(
                 Path,    // input volume mount point or directory
                 Target,  // output volume name buffer
                 BUFSIZE  // size of volume name buffer
               );
    
       if (!bFlag)
          _tprintf (TEXT("\tAttempt to get volume name for %s failed.\n"), Path);
       else 
          _tprintf (TEXT("\tTarget of the volume mount point is %s.\n"), Target);
    
       // Now, either get the next mount point and return it, or return a 
       // value indicating there are no more mount points.
    
       bFlag = FindNextVolumeMountPoint(
                  hPt,        // handle to scan
                  PtBuf,      // pointer to output string
                  dwPtBufSize // size of output buffer
               );
      return (bFlag);
    }
    
    // Process each volume. This makes maintenance easier than doing it
    // in line. The Boolean result indicates whether there is another
    // volume to be scanned.
    
    BOOL ProcessVolume (HANDLE hVol, TCHAR *Buf, int iBufSize)
    {
       BOOL bFlag;           // generic results flag for return
       HANDLE hPt;           // handle for mount point scan
       TCHAR PtBuf[BUFSIZE]; // string buffer for mount points
       DWORD dwSysFlags;     // flags that describe the file system
       TCHAR FileSysNameBuf[FILESYSNAMEBUFSIZE];
    
       _tprintf (TEXT("Volume found is \"%s\".\n"), Buf);
    
       // Is this volume NTFS? 
       GetVolumeInformation( Buf, NULL, 0, NULL, NULL,
                             &dwSysFlags, FileSysNameBuf, 
                             FILESYSNAMEBUFSIZE);
    
       // Detect support for reparse points, and therefore for volume 
       // mount points, which are implemented using reparse points.
    
       if (! (dwSysFlags & FILE_SUPPORTS_REPARSE_POINTS)) 
       {
          _tprintf (TEXT("\tThis file system does not support volume mount points.\n"));
       } 
       else 
       {
          // Start processing mount points on this volume. 
    
          hPt = FindFirstVolumeMountPoint(
                      Buf, // root path of volume to be scanned
                    PtBuf, // pointer to output string
                   BUFSIZE // size of output buffer
                );
    
          if (hPt == INVALID_HANDLE_VALUE)
          {
             _tprintf (TEXT("\tNo volume mount points found!\n"));
          } 
          else 
          {
             // Process the volume mount point.
             bFlag = ProcessVolumeMountPoint (hPt, PtBuf, BUFSIZE, Buf);
    
             // Do while we have volume mount points to process.
             while (bFlag) 
                bFlag = ProcessVolumeMountPoint (hPt, PtBuf, BUFSIZE, Buf);
    
             FindVolumeMountPointClose(hPt);
           }
       }
    
      // Stop processing mount points on this volume. 
    
       bFlag = FindNextVolume(
                 hVol,    // handle to scan being conducted
                 Buf,     // pointer to output
                 iBufSize // size of output buffer
               );
    
       return (bFlag); 
    }
    
    int main(void)
    {
       TCHAR buf[BUFSIZE];      // buffer for unique volume identifiers
       HANDLE hVol;             // handle for the volume scan
       BOOL bFlag;              // generic results flag
    
       // Open a scan for volumes.
       hVol = FindFirstVolume (buf, BUFSIZE );
    
       if (hVol == INVALID_HANDLE_VALUE)
       {
          _tprintf (TEXT("No volumes found!\n"));
          return (-1);
       }
    
       // We have a volume; process it.
       bFlag = ProcessVolume (hVol, buf, BUFSIZE);
    
       // Do while we have volumes to process.
       while (bFlag) 
       {
          bFlag = ProcessVolume (hVol, buf, BUFSIZE);
       }
    
       // Close out the volume scan.
       bFlag = FindVolumeClose(
                  hVol  // handle to be closed
               );
    
       return (bFlag);
    }
    

Anmelden zum Antworten