词条 | GetDrive |
释义 | C语言函数函数简介函数名称:_getdrive 函数功能:返回当前的磁盘驱动器,1代表A盘,2代表B盘,依次类推 函数原型:int _getdrive( void ); 所属库名:direct.h 程序示例#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:\" ); // 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( '\' ); } } // Restore original drive. _chdrive( curdrive ); } VB中GetDrive 方法描述返回一个与指定路径中的驱动器相对应的 Drive 对象。语法object.GetDrive drivespecGetDrive 方法语法有如下几部分:部分描述Object必需的。始终是一个 FileSystemObject 的名字。Drivespec必需的。drivespec参数可以是一个驱动器字符(c)、一个驱动器字符加一个冒号(c:)、一个驱动器字符加冒号和路径分隔符(c:\\)或任何网络共享的说明(\\\\computer2\\share1)。说明对于网络共享,要进行检查以确保共享存在。如果 drivespec 不符合任何一种可以接受的形式或者不存在,则发生一个错误。对一个普通路径字符串调用 GetDrive 方法,使用下面步骤得到一个适合作为 drivespec 使用的字符串:DriveSpec = GetDriveName(GetAbsolutePathName(Path)) |
随便看 |
百科全书收录4421916条中文百科知识,基本涵盖了大多数领域的百科知识,是一部内容开放、自由的电子版百科全书。