다음을 통해 공유


_getdrive

현재 드라이브를 가져옵니다.

중요

이 API는 Windows 런타임에서 실행되는 응용 프로그램에서 사용할 수 없습니다.자세한 내용은 /ZW에서 지원하지 않는 CRT 함수를 참조하십시오.

int _getdrive( void );

반환 값

현재 (기본) 드라이브를 반환 (1 = A, B = 2, 및 등). 반환되는 오류가 없습니다.

요구 사항

루틴

필수 헤더

_getdrive

<direct.h>

호환성 정보에 대한 자세한 내용은 호환성을 참조하십시오.

예제

// 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 항목

System::Environment::CurrentDirectory

참고 항목

참조

디렉터리 제어

_chdrive

_getcwd, _wgetcwd

_getdcwd, _wgetdcwd