PRB: _dos_findfirst() with _A_VOLID on MS-DOS vs. Windows NT

Last reviewed: July 22, 1997
Article ID: Q125496
7.00 | 1.00 1.50 1.51 MS-DOS | WINDOWS kbprg kbprb

The information in this article applies to:

  • The C Run-time (CRT) included with:

        - Microsoft C/C++ version 7.0
        - Microsoft Visual C++ for Windows, versions 1.0, 1.5, and 1.51
    

SYMPTOMS

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.

CAUSE

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.

RESOLUTION

In order to avoid different behavior when getting the volume ID using _dos_findfirst(), always specify the root directory when making the call.

STATUS

This behavior is by design.

MORE INFORMATION

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

Sample Code

/* 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


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 22, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.