Exportar (0) Imprimir
Expandir todo
div
EOF
Expandir Minimizar
Este artículo proviene de un motor de traducción automática. Mueva el puntero sobre las frases del artículo para ver el texto original. Más información.
Traducción
Original

_getdrive

Obtiene la unidad de disco actual.

Nota importante Importante

Esta API no se puede utilizar en las aplicaciones que se ejecutan en tiempo de ejecución de Windows. Para obtener más información, vea Funciones CRT no compatibles con /ZW.

int _getdrive( void );

Devuelve la unidad (predeterminada) actual (1=A, 2=B, etc.). No hay retorno de error.

Rutina

Encabezado necesario

_getdrive

<direct.h>

Para obtener más información de compatibilidad, vea Compatibilidad en la Introducción.

// 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 );
}
Las unidades disponibles son: A: (El directorio actual es A: el directorio de \)c: (current \) C: (Current directory is C:\) E: (Current directory is E:\testdir\bin) F: (Current directory is F:\) G: (Current \) C: (Current directory is C:\) E: (Current directory is E:\testdir\bin) F: (Current directory is F:\) G: (Current c:\) e: (current \) C: (Current directory is C:\) E: (Current directory is E:\testdir\bin) F: (Current directory is F:\) G: (Current \) C: (Current directory is C:\) E: (Current directory is E:\testdir\bin) F: (Current directory is F:\) G: (Current e:\testdir\bin) f: (current \) C: (Current directory is C:\) E: (Current directory is E:\testdir\bin) F: (Current directory is F:\) G: (Current \) C: (Current directory is C:\) E: (Current directory is E:\testdir\bin) F: (Current directory is F:\) G: (Current f:\) g: (current es G:\)

Adiciones de comunidad

AGREGAR
Mostrar:
© 2014 Microsoft