HOWTO: Tell Whether an App Runs in VB Design EnvironmentLast reviewed: February 26, 1997Article ID: Q118819 |
3.00
WINDOWS
kbenv kbprg kbcode
The information in this article applies to:
SUMMARYThis article describes how a Visual Basic application can determine whether it is running in the design environment or as an executable file. Two ways that Visual Basic does this are explained.
MORE INFORMATIONVisual Basic provides the APP object, which has the property EXENAME. APP.EXENAME reports the name of the executable file when it runs as an executable file. However, in the design environment, APP.EXENAME reports the name of the project. If you use different names for the project and the executable file, then you can use APP.EXENAME to determine whether an application is running in the Visual Basic design environment or as an executable file. You can also use the Windows API to determine whether an application is running in the Visual Basic Design Environment or as an executable file. When running in the design environment, the application's module name is "VB." However, as an executable file the module name matches the executable file name that is chosen when compiling the application to an executable file from Visual Basic.
ExampleYou can determine the module name by using the functions GetCurrentTask() and TaskFindHandle() from the Windows API. The following example illustrates how to use the functions to determine whether the application is running in the Visual Basic design environment:
Sub Form_Load () Me.Show If VBDesignEnvironment() Then Print "Design Environment" Else Print "Executable" End If End Sub
Notes
|
KBCategory: kbenv kbprg kbcode
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |