_getdrive
現在のディスク ドライブを取得します。
重要 |
---|
この API は、Windows のランタイムで実行するアプリケーションで使用することはできません。詳細については、でサポート /ZW CRT 関数" "を参照してください。 |
int _getdrive( void );
戻り値
現在の (既定の) ドライブ (1=A、2=B など) を返します。エラーの戻り値はありません。
必要条件
ルーチン |
必須ヘッダー |
---|---|
_getdrive |
<direct.h> |
互換性の詳細については、「C ランタイム ライブラリ」の「互換性」を参照してください。
使用例
// 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