dsk_ishd.c

来自「[随书类]Dos6.0源代码」· C语言 代码 · 共 64 行

C
64
字号
/***************************************************************************/
/*																									*/
/*	DSK_ISHD.C																					*/
/*																									*/
/*		Copyright (c) 1991 - Microsoft Corp.											*/
/*		All rights reserved.																	*/
/*		Microsoft Confidential																*/
/*                                                                         */
/* Determines if a disk is a valid hard disk. The requirements are that		*/
/* the drive letter is C: or greater, the drive exists, is a local drive,	*/
/* is not removeable and is not the MS-DOS RamDrive.								*/
/*																									*/
/*	int IsValidHardDrive( char chDrive )												*/
/*																									*/
/*	ARGUMENTS:	chDrive	- The drive letter of the drive to check				*/
/*	RETURNS:		int		- TRUE if a hard disk else FALSE							*/
/*																									*/
/* Created 09-01-90 johnhe																	*/
/***************************************************************************/

#include		<alias.h>
#include		<disk_io.h>

/***************************************************************************/

int IsValidHardDrive( char chDrive )
{
	int	iDrvNum;

	iDrvNum = (int)chDrive - ('A' - 1);

	if ( chDrive >= 'C' )
		if ( IsValidDrive( chDrive ) )
			if ( IsLocalDrive( iDrvNum ) )
				if ( !IsRemoveable( iDrvNum ) )
					if ( !IsRamDrive( chDrive ) )
						return( TRUE );
	return( FALSE );
}

// This is just like IsValidHardDrive, except that it makes sure the 
// drive is formatted also.
int IsReallyValidHardDrive( char chDrive )
{
#define SECTOR_SIZE    512

    char  *pchBuffer;
    
    if (!IsValidHardDrive(chDrive))
        return( FALSE );

    pchBuffer = GetMemory(SECTOR_SIZE);

    if (GetBootSector(chDrive, pchBuffer) == OK)
    {
       FreeMemory(pchBuffer);
       return( TRUE );
    }   

    FreeMemory(pchBuffer);
    return ( FALSE );   
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?