Compartilhar via


_getdrive

Obtém a unidade de disco atual.

Observação importanteImportante

Este API não pode ser usado em aplicativos executados em Tempo de Execução do Windows.Para obter mais informações, consulte Funções de CRT não suportadas com /ZW.

int _getdrive( void );

Valor de retorno

Retorna a unidade atual (padrão) (1=A, 2=B, e assim por diante).Não há nenhum retorno de erro.

Requisitos

Rotina

Cabeçalho necessário

_getdrive

<direct.h>

Para mais informações, consulte Compatibilidade de compatibilidade na introdução.

Exemplo

// 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 );
}
  

Equivalência do .NET Framework

System::Environment::CurrentDirectory

Consulte também

Referência

Controle de diretório

_chdrive

_getcwd, _wgetcwd

_getdcwd, _wgetdcwd