ID: Q125496
7.00 | 1.00 1.50 1.51 MS-DOS | WINDOWS kbprg kbprb
The information in this article applies to:
- Microsoft C/C++ version 7.0
- Microsoft Visual C++ for Windows, versions 1.0, 1.5, and 1.51
A program calling _dos_findfirst() with the _A_VOLID attribute set behaves differently when run under MS-DOS versus Windows NT. When it's run under MS- DOS, the call can specify any subdirectory and get the volume ID back, if one exists. However when it's run under Windows NT, you will only get the volume ID back if the call specifies the root directory.
This is not a problem with the C Run-time library.
The _dos_findfirst() function puts the user-supplied parameters into the appropriate registers and issues an INT 21h call. The differences observed are due to different operating system implementations of INT 21h Function 4Eh.
In order to avoid different behavior when getting the volume ID using _dos_findfirst(), always specify the root directory when making the call.
This behavior is by design.
The following sample code demonstrates this behavior. Make sure you have a volume ID defined for your C drive and that you have a C:\DOS subdirectory containing at least one file. Then run the program first under MS-DOS, then under Windows NT.
The output when run under MS-DOS is:
_dos_findfirst succeeded in the root directory
_dos_findfirst succeeded in the DOS directory
The output when run under Windows NT is:
_dos_findfirst succeeded in the root directory
_dos_findfirst failed in the DOS directory
/* Compile options needed: none
*/
#include <stdio.h>
#include <dos.h>
void main()
{
struct _find_t info;
if (!_dos_findfirst("c:\\*.*",_A_VOLID,&info))
printf("_dos_findfirst succeeded in the root directory\n");
else printf("_dos_findfirst failed in the root directory\n");
if (!_dos_findfirst("c:\\dos\\*.*",_A_VOLID,&info))
printf("_dos_findfirst succeeded in the DOS directory\n");
else printf("_dos_findfirst failed in the DOS directory\n");
}
Additional reference words: 7.00 1.00 1.50 KBCategory: kbprg kbprb KBSubcategory: CRTIss Keywords : kb16bitonly
Last Reviewed: July 23, 1997