The information in this article applies to:
SUMMARYThis article describes how to determine whether Visual Basic is presently running an EXE or DLL program. This is useful to know if both an EXE and a DLL version of a program have been created, and different actions need to take place based on which version is loaded. MORE INFORMATION
There are several ways to determine whether a running program was loaded as
an EXE or DLL.
Method 1 - Place the information in one of the resource stampsChoose the Options button when making the EXE or DLL. In the Version Information section, select File Description, and type in the type of file to be compiled. To test this in the running program, enter the code below to see a MsgBox with the correct type:
Method 2 - Conditional CompilationIf the version information fields are being used, use Conditional Compilation to determine if a program is a DLL or an EXE, as in the following code:
Before compiling the EXE, from the Tools menu, select Options, select Advanced Tab, and type the following in the Conditional Compilation Arguments field:
If a DLL is being compiled, type the following in the Conditional Compilation Arguments field:
In Method 2, code that is not required for a DLL or an EXE is not compiled. This is significant if a DLL and an EXE version of a program need to behave differently. Method 3 - Use the Windows API to dynamically determine the file extensionIf the Instance handle of the program is passed to the GetModuleFileName API function, the full path is returned to the program. Microsoft Visual Basic exposes the hInstance as a property of the App object. For example:
Additional query words: kbVBp400 kbVBp500 kbVBp600 kbVBp kbdsd kbDSupport KBWIN32SDK KBAPI
Keywords : kbGrpVB |
Last Reviewed: January 5, 2000 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |