PRB: VB Error Using Shell: Cannot Find DLL, Insert in Drive A

Last reviewed: June 21, 1995
Article ID: Q80404
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

SYMPTOMS

When a Visual Basic application shells to a Microsoft Windows-based application that expects to find a dynamic link library (DLL) in its own directory, Visual Basic may generate the following error message and fail to start the application:

   Cannot Find <DLL NAME>, Please Insert in Drive A

CAUSE

This error occurs because the application being shelled to expects to find the DLL in the current directory, the MS-DOS path, or the Windows directory. Shelling to an application in code does not change the current directory, even if you specify the path to the application in the Shell statement.

RESOLUTION

One solution is to use Visual Basic for Windows' ChDir statement to change the current directory to the directory containing the DLL before attempting to shell to the application. An alternative solution is to copy the DLL to the Windows directory, or include the path where the DLL is located in the MS-DOS path.

MORE INFORMATION

The following is a pseudocode example that shows how to use the ChDir statement to make the application's directory the current directory. The C:\APPS directory and the .EXE name MYAPP.EXE are arbitrary names selected to represent the location of the application being shelled to and an .EXE name, respectively.

    Sub Form_Click ()
        ChDir "c:\Apps"     ' The name of the directory containing
                            ' the needed DLL.
        x% = Shell("c:\Apps\MyApp.EXE", 1)
    End Sub

NOTE: If the application is on a different drive, use the ChDrive statement first to change drives before using the ChDir statement.


Additional reference words: 1.00 2.00 3.00
KBCategory: kbenv kbprg kbprb
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.