函式簡介
函式名稱:_wgetdcwd
函式功能及返回值:返回指定的驅動器上當前工作目錄的完整路徑(絕對路徑)
所屬庫:direct.h或wchar.h
函式原型:
wchar_t *_wgetdcwd(
int drive,
wchar_t *buffer,
int maxlen
);
相關函式:_getdcwd
程式示例
// 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 );
}