HOWTO: Check if Program Is Running in the IDE or an EXE FileLast reviewed: December 5, 1997Article ID: Q177636 |
The information in this article applies to:
SUMMARYThis article demonstrates how to determine if your program is running in the Visual Basic IDE or as a compiled executable file. You might want to check where your program is running if you need to add debugging information that would not be visible in the compiled version of your program.
MORE INFORMATIONThere are two methods you can use to determine if your program is running from the IDE or the EXE.
Method 1: EXE File Name Differs from Project NameThe App object contains general information about the program, such as the executable file name. If the project name and the compiled version of the project have different file names, then you can use the App.EXEName property to determine if the EXE is running or if your project is running in the IDE. If the program is running from the Visual Basic IDE, the EXEName property returns the project name. When a program is running from an executable, the EXEName property contains the EXE file name.
Method 2: EXE File Name and the Project Name Are the SameIf the project name and the compiled version share the same name, then use the GetModuleFileName API function to determine if your program is running from the IDE or from a compiled version. GetModuleFileName retrieves the full path and filename for the executable file containing the specified module. If the function returns a path to the Visual Basic development environment (IDE) file, VB5.EXE, then the program is running in the IDE. Otherwise, the program is running from an executable file. GetModuleFileName requires the following arguments:
Sample Project
REFERENCESFor information about determining if a 16-bit Visual Basic application is running in the design environment, please see the following article in the Microsoft Knowledge Base:
ARTICLE-ID: Q118819 TITLE : HOWTO: Tell Whether an App Runs in VB Design Environment |
Additional query words: exe executable running design-time run-time runtime
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |