複製鏈接
請複製以下鏈接發送給好友

GetDrive

鎖定
GetDrive是一個C語言函數。
中文名
GetDrive
類    別
C語言函數
函數功能
返回當前的磁盤驅動器
函數原型
int _getdrive( void )

GetDriveC語言函數

GetDrive函數簡介

函數名稱:_getdrive
函數功能:返回當前的磁盤驅動器,1代表A盤,2代表B盤,依次類推
函數原型:int _getdrive( void );
所屬庫名:direct.h

GetDrive程序示例

#include
#include
#include
#include
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 );
}

GetDriveVB中GetDrive 方法

描述返回一個與指定路徑中的驅動器相對應的 Drive 對象。語法object.GetDrive drivespecGetDrive 方法語法有如下幾部分:部分描述Object必需的。始終是一個 FileSystemObject 的名字。Drivespec必需的。drivespec參數可以是一個驅動器字符(c)、一個驅動器字符加一個冒號(c:)、一個驅動器字符加冒號和路徑分隔符(c:\)或任何網絡共享的説明(\\computer2\share1)。説明對於網絡共享,要進行檢查以確保共享存在。如果 drivespec 不符合任何一種可以接受的形式或者不存在,則發生一個錯誤。對一個普通路徑字符串調用 GetDrive 方法,使用下面步驟得到一個適合作為 drivespec 使用的字符串:DriveSpec = GetDriveName(GetAbsolutePathName(Path))