ChDrive,C語言函式名,函式功能是改變當前的工作驅動器。
C語言函式,函式簡介,程式示例,VB,
C語言函式
函式簡介
函式名稱:_chdrive
所屬庫名:direct.h
函式原型:int _chdrive( int drive );
返回值:改變驅動器成功則返回0,否則返回-1
程式示例
下面的程式示例來自MSDN
// 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 );
}