VB CURDIR$ Function Not Reliable to Determine Program Location

Last reviewed: June 21, 1995
Article ID: Q80611
The information in this article applies to:

- Standard and Professional Editions of Microsoft Visual Basic for

  Windows, versions 2.0 and 3.0
- Microsoft Visual Basic programming system for Windows, version 1.0

SUMMARY

The CURDIR$ function returns the path to the current directory on the currently selected drive. Because the current directory is not necessarily the directory where the current Visual Basic program resides, the CURDIR$ function is not a reliable means for determining the location of the currently executing program. This information applies to the CURDIR$ function, and to the drive list box, directory list box, and file list box controls in Visual Basic.

MORE INFORMATION

You can use any of the following methods to start a program under Windows:

  • From the MS-DOS prompt, type:

          WIN drive:\pathname\program name
    
  • From Windows Program Manager, choose Run from the File menu, and enter the full pathname of the executable program.
  • From Windows File Manager, choose Run from the File menu, and enter the full path of the executable program.
  • From Windows Program Manager, choose New from the File menu, and create a new program item for the executable program. Double-click the resulting icon.
  • From Windows File Manager, use the mouse to choose the appropriate drive and directory containing the executable file, and double-click the executable filename.

If the program is launched using the first, third, or fifth method above, the CURDIR$ value will return the current directory at the time Windows was launched or at the time the program was started from File Manager. The current directory can be checked by opening File Manager and reading the current directory from the bar below the drive buttons; for the fifth method, the File Manager's current directory will actually be the directory where the started program resides.

If the program is launched using the second method from the Windows Program Manager, the CURDIR$ value will be the path to the location of the program that was started.

If the program is launched using the fourth method, the CURDIR$ value is the working directory you specified for the icon, or if you left the working directory blank, CURDIR$ returns the Windows directory.

NOTE: The current directory of an MS-DOS session does not necessarily indicate the current directory that will be returned by CURDIR$.


Additional reference words: 1.00 2.00 3.00
KBCategory: kbenv kbprg
KBSubcategory: EnvtRun


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: June 21, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.