beckingh
asked on
How to tell if running in development mode.
I pop up a message box when the program starts, but I don't want it to come up if I am running from the IDE. How can I tell if I am running from an Exe or from the IDE?
Thanks
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I had a similar problem and found the solution on MSDN itself. Here is how it works.
1) Keep the exe name different from the project.
2) If the exe has the same name as the project, 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 file, VB5.EXE, then the program is running in the IDE. Otherwise, the program is running from an executable file.
1) Keep the exe name different from the project.
2) If the exe has the same name as the project, 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 file, VB5.EXE, then the program is running in the IDE. Otherwise, the program is running from an executable file.
ASKER
Here's the code I ended up using. Thanks all.
Function IsIDE() As Boolean
On Error Resume Next
Debug.Print 1 / 0
IsIDE = Err.Number <> 0
Err.Clear
End Function
Function IsIDE() As Boolean
On Error Resume Next
Debug.Print 1 / 0
IsIDE = Err.Number <> 0
Err.Clear
End Function
Private Sub Form_Load()
MsgBox IsIDE
End Sub
Private Function IsIDE() As Boolean
On Error Resume Next
Debug.Assert 1 / 0
If Err.Number = 0 Then
IsIDE = False
Else
IsIDE = True
End If
End Function
Option #2
Conditional Compilation