DOS6.2 + BC3.1
实际项目中是图形界面,drive=0,1 时(A:,B:),_chdrivee有效,
但_dos_getdiskfree出错,应该是在执行21号中断是提示出错信息(General failure reaing drive A),破坏图形环境。
另外用 DUSE49 加载驱动参数为 drivers=3,则后两个盘符也会提示出错信息(Invalid unit reading drive F)。
Windows XP 下执行是光驱和虚拟光驱报错。
有什么办法不出现提示信息?自己知道这个驱动器不能用就行了。
代码如下:
实际项目中是图形界面,drive=0,1 时(A:,B:),_chdrivee有效,
但_dos_getdiskfree出错,应该是在执行21号中断是提示出错信息(General failure reaing drive A),破坏图形环境。
另外用 DUSE49 加载驱动参数为 drivers=3,则后两个盘符也会提示出错信息(Invalid unit reading drive F)。
Windows XP 下执行是光驱和虚拟光驱报错。
有什么办法不出现提示信息?自己知道这个驱动器不能用就行了。
代码如下:
C/C++ code
// crt_getdrive.c
// compile with: /c
// Illustrates drive functions including:
// _getdrive _chdrive _getdcwd
//
#include <dos.h>
#include <stdio.h>
#include <direct.h>
#include <stdlib.h>
#include <ctype.h>
int main( void )
{
int ch, drive, curdrive;
long LM;
static char path;
struct diskfree_t diskspace;
curdrive = _getdrive(); // Save current drive.
for( drive = 1; drive <= 26; drive++ ) // If we can switch to the drive, it exists.
{
if( !_chdrive( drive ) )
{
printf( "%c:", drive + 'A' - 1 );
if( _getdcwd( drive, path, _MAX_PATH ) != NULL )
printf( " (Current directory is %s)", path );
if(0==_dos_getdiskfree(drive,&diskspace))
{
LM=(unsigned long)(diskspace.avail_clusters)
*(unsigned long)(diskspace.sectors_per_cluster)
*(unsigned long)(diskspace.bytes_per_sector)/1024/1024;
printf( " %ld MBytes free",LM);
}
putchar( '\n' );
}
}
_chdrive( curdrive ); // Restore original drive.
}
