HOWTO: Tell Whether an App Runs in VB Design Environment 
Author Message
 HOWTO: Tell Whether an App Runs in VB Design Environment

I need to activate some code while I am debugging, but not have it
acccessable when I run the EXE. I am currently using code that I
appropriated from Q118819. I found out recently that this technique ONLY
works in WIN16.  But now I need to port the program to WIN32 under win95
and NT. To further complicate things I am currently using VB4 (with hope
to switch to VB5 but not for a while). How do I do it?  The knowledge
base came up empty for me.  Any suggestions, article or book references,
anything would be helpful. Thanks.



Fri, 06 Oct 2000 03:00:00 GMT  
 HOWTO: Tell Whether an App Runs in VB Design Environment

There is a system variable that you could use for a conditional compile that
will tell your program whether it is running as a standalone EXE or from
within the IDE.  Damed if I can remember which one it is now.  Anyone else
remember?  I only used it once, and it was a while ago.

--

Tony Selke

(please remove the _No-Junk-Mail_ prior to responding)

/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\

Quote:
>I need to activate some code while I am debugging, but not have it
>acccessable when I run the EXE.



Sat, 07 Oct 2000 03:00:00 GMT  
 HOWTO: Tell Whether an App Runs in VB Design Environment

I've been using this:

Public Function VBDesignMode() As Boolean
   '
   ' If VB5.EXE is running in the current process space, return TRUE
   '
   ' If VB5.EXE is running as another process, GetModuleHandle returns 0
   Dim hModule As Long
   hModule = GetModuleHandle("VB5.EXE")
   VBDesignMode = (hModule > 0)
End Function

Jonas
TRION Technologies

Quote:

>I need to activate some code while I am debugging, but not have it
>acccessable when I run the EXE. I am currently using code that I
>appropriated from Q118819. I found out recently that this technique ONLY
>works in WIN16.  But now I need to port the program to WIN32 under win95
>and NT. To further complicate things I am currently using VB4 (with hope
>to switch to VB5 but not for a while). How do I do it?  The knowledge
>base came up empty for me.  Any suggestions, article or book references,
>anything would be helpful. Thanks.



Sat, 07 Oct 2000 03:00:00 GMT  
 HOWTO: Tell Whether an App Runs in VB Design Environment

On Mon, 20 Apr 1998 18:09:07 -0700, "Steven S. Silver"

Quote:

>I need to activate some code while I am debugging, but not have it
>acccessable when I run the EXE. I am currently using code that I
>appropriated from Q118819. I found out recently that this technique ONLY
>works in WIN16.  But now I need to port the program to WIN32 under win95
>and NT. To further complicate things I am currently using VB4 (with hope
>to switch to VB5 but not for a while). How do I do it?  The knowledge
>base came up empty for me.  Any suggestions, article or book references,
>anything would be helpful. Thanks.

I haven't read this KB article, but the code I use is:

Function RunningInIDE() As Boolean
    On Error Resume Next
    Debug.Print 9 / 0
    If Err Then
        RunningInIDE = True
    Else
        RunningInIDE = False
    End If
    On Error GoTo 0
End Function



Sat, 07 Oct 2000 03:00:00 GMT  
 HOWTO: Tell Whether an App Runs in VB Design Environment

You don't need to know a system variable, just use this simple Function:

Function DesignTime() As Boolean
    On Error Resume Next
    Debug.Print 0 / 0
    If Err = 0 Then
        DesignTime = False
    Else
        DesignTime = True
    End If
End Function

The debug-object doesn't cause an div by zero error when running as
standalone-EXE!
Tricky, eh?



Quote:
> There is a system variable that you could use for a conditional compile
that
> will tell your program whether it is running as a standalone EXE or from
> within the IDE.



Tue, 10 Oct 2000 03:00:00 GMT  
 HOWTO: Tell Whether an App Runs in VB Design Environment

If you use _this_ method, you can even tell from your ActiveX DLL is it is
being called from the IDE:

Public Function VBDesignMode() As Boolean
   '
   ' If VB5.EXE is running in the current process space, return TRUE
   '
   ' If VB5.EXE is running as another process, GetModuleHandle returns 0
   Dim hModule As Long
   hModule = GetModuleHandle("VB5.EXE")
   VBDesignMode = (hModule > 0)
End Function

I wrote this when I realized that the "Debug.print 0 / 0" method will fail
if a compiled component needs to know if it's is being used in the IDE.

Jonas
TRION Technologies

Quote:
>You don't need to know a system variable, just use this simple Function:

>Function DesignTime() As Boolean
>    On Error Resume Next
>    Debug.Print 0 / 0
>    If Err = 0 Then
>        DesignTime = False
>    Else
>        DesignTime = True
>    End If
>End Function

>The debug-object doesn't cause an div by zero error when running as
>standalone-EXE!
>Tricky, eh?



>> There is a system variable that you could use for a conditional compile
>that
>> will tell your program whether it is running as a standalone EXE or from
>> within the IDE.



Tue, 10 Oct 2000 03:00:00 GMT  
 HOWTO: Tell Whether an App Runs in VB Design Environment

Quote:
>I need to activate some code while I am debugging, but not have it
>acccessable when I run the EXE.

Can't you just check the value returned by App.EXEName?
"Returns the root name of the executable file (without the extension) that is
currently running. If running in the development environment, returns the name
of the project."

Art



Wed, 11 Oct 2000 03:00:00 GMT  
 HOWTO: Tell Whether an App Runs in VB Design Environment

All well and good unless your project name and exe name are identicle.

:)

--

Tony Selke

(please remove the _No-Junk-Mail_ prior to responding)

/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\

Quote:

>>I need to activate some code while I am debugging, but not have it
>>acccessable when I run the EXE.

>Can't you just check the value returned by App.EXEName?
>"Returns the root name of the executable file (without the extension) that
is
>currently running. If running in the development environment, returns the
name
>of the project."

>Art



Wed, 11 Oct 2000 03:00:00 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. Running as .EXE or running in VB Design Environment

2. Q: How can I Tell whether in Design or Runtime Mode

3. Q: How can I Tell whether in Design or Runtime Mode

4. How can you tell whether an app is 16-bit or 32-bit

5. VB5 program determining whether it's running in the IDE environment

6. Determine whether running in design mode or not

7. ?: Want to determine whether program runs in design mode or not

8. how to tell at runtime if ran application from exe or from development environment

9. How tell if running in exe or vb4 Dev environment

10. How to tell whether installation media is full or upgrde for VB 6 Enterprise

11. Check whether shelled app is still running?

12. Determining whether an app is running

 

 
Powered by phpBB® Forum Software