Share via


_getdrive

Ruft das aktuelle Laufwerk ab.

Wichtig

Diese API kann nicht in Anwendungen verwendet werden, die in Windows-Runtime ausgeführt werden.Weitere Informationen finden Sie unter CRT-Funktionen nicht mit /ZW unterstützt.

int _getdrive( void );

Rückgabewert

Gibt das aktuelle (Standard-)Laufwerk zurück (1 = A, 2 = B usw.). Es gibt keine Fehlerrückgabe.

Anforderungen

Routine

Erforderlicher Header

_getdrive

<direct.h>

Weitere Informationen zur Kompatibilität finden Sie unter Kompatibilität.

Beispiel

// crt_getdrive.c
// compile with: /c
// Illustrates drive functions including:
//    _getdrive       _chdrive        _getdcwd
//

#include <stdio.h>
#include <direct.h>
#include <stdlib.h>
#include <ctype.h>

int main( void )
{
   int ch, drive, curdrive;
   static char path[_MAX_PATH];

   // Save current drive.
   curdrive = _getdrive();

   printf( "Available drives are:\n" );

   // If we can switch to the drive, it exists.
   for( drive = 1; drive <= 26; drive++ )
   {
      if( !_chdrive( drive ) )
      {
         printf( "%c:", drive + 'A' - 1 );
         if( _getdcwd( drive, path, _MAX_PATH ) != NULL )
            printf( " (Current directory is %s)", path );
         putchar( '\n' );
      }
   }

   // Restore original drive.
   _chdrive( curdrive );
}
  

.NET Framework-Entsprechung

System::Environment::CurrentDirectory

Siehe auch

Referenz

Verzeichnissteuerung

_chdrive

_getcwd, _wgetcwd

_getdcwd, _wgetdcwd