Michka,

Here is a modification to this trick. The advantage being that if you have
'Break on all errors' set then this code will still work. I usually check
IsDev at the start of my app so I don't bother showing registration details
etc. This pretty much kills any chance of using break on all error with the
1/0 method.

Private Property Get IsDev() As Boolean
Debug.Assert SetTrue(IsDev) Or True
End Property
Private Function SetTrue(Value As Boolean) As Boolean
Value = True
End Function

Michael Culley

"Michael \(michka\) Kaplan" <former_mvp@spamless.trigeminal.spamless.com>
wrote:
>Well, the Debug.Assert 1/0 trick is still the one that is most lightweight,
>I think. :-)
>
>--
>?MichKa
>(insensitive fruitarian)
>
>random junk of dubious value, a multilingual website, the
>54-language TSI Form/Report to Data Access Page Wizard,
>and lots of replication "stuff" at the (no scripts required!)
>http://www.trigeminal.com/
>
>?
>"Brad Martinez" <btmtz@msn.com.nospam> wrote in message
>news:38b72ed2@news.devx.com...
>> Matthew,
>>
>> >What I need to do is always be able to determine whether the app is in

an
>> >IDE design mode, or whether the app is running (either in the IDE or

>compiled).
>>
>> Though I've never tested it, here's a little morsel I saved from
>> a long lost poster to this group that might do the deed...
>>
>>
>> -----Original Message-----
>> From: John Hamaker <jhamaker@cyberhighway.net>
>> Newsgroups: vb.api
>> Date: Thursday, January 28, 1999 6:42 PM
>> Subject: Re: How to detect if IDE or EXE
>>
>>
>> >Hi,
>> >
>> >>I believe that this approach may do the trick.
>> >
>> >You might want to try this too, it's faster (as if that matters <g>).
>> >
>> >You can find out if you're compiled (without the divide by 0 trick) and

>whether
>> >you're in the IDE or an executable after the DLL/OCX is compiled.
>> >
>> >--
>> >John Hamaker

>>
>> <attachment>
>>
>> ' RunTimeInfo Class
>> ' Written by John Hamaker
>>
>> Option Explicit
>>
>> Private Declare Function GetModuleHandle Lib "kernel32" Alias

>"GetModuleHandleA" (ByVal lpFileName As Long) As Long
>> Private Declare Function GetProcAddress Lib "kernel32" (ByVal hModule

As
>Long, ByVal lpszProc As String) As Long
>>
>> Private mCompiled As Boolean
>> Private mDevelopment As Boolean
>>
>> Private Sub Class_Initialize()
>>
>> Dim hModule As Long
>>
>> ' Get module that started this instance of the DLL.
>>
>> hModule = GetModuleHandle(0)
>>
>> ' If our instance is the same as our creator's instance,
>> ' then we're running in the IDE.
>>
>> mCompiled = hModule <> App.hInstance
>>
>> ' The "_VB_CALLBACK_GETHWNDMAIN_@4" function is exported by
>> ' all 32 bit versions of Visual Basic [4-6]
>>
>> ' Find the address for the "_VB_CALLBACK_GETHWNDMAIN_@4"
>> ' function in the module that created this instance.
>>
>> ' If the propcedure is found, we're running in the IDE... If not,
>> ' we're running in a compiled EXE.
>>
>> mDevelopment = GetProcAddress(hModule, "_VB_CALLBACK_GETHWNDMAIN_@4")
>>
>> End Sub
>>
>> Public Property Get Compiled() As Boolean
>>
>> Compiled = mCompiled
>>
>> End Property
>>
>> Public Property Get Development() As Boolean
>>
>> Development = mDevelopment
>>
>> End Property
>>
>> </attachment>
>>
>> Yes?
>>
>> --
>> Brad Martinez, http://www.mvps.org
>> Please direct questions/replies to the newsgroup
>>
>>
>> Matthew Cromer wrote in message <38b69168$1@news.devx.com>...
>> >
>> >I need to create a function that can determine whether or not the

>application
>> >is running.
>> >
>> >Here is the problem. I have a number of custom UserControls which

>contain
>> >other custom UserControls. I need to, at any time, be able to determine
>> >when the UserControls are running because the IDE is displaying them,

or
>> >whether the entire app is actually running.
>> >
>> >Ambient.Usermode works for controls that are running directly on a form.
>> > Unfortunately, it doesn't work if controls contain other controls.

The
>> >"innermost" control will display a value for Ambient.Usermode that is

the
>> >same, regardless of whether the entire app is in design mode or run mode.
>> >
>> >What I need to do is always be able to determine whether the app is in

an
>> >IDE design mode, or whether the app is running (either in the IDE or

>compiled).
>> >
>> >The best thing that I have been able to come up with is look for a window
>> >on the thread with a class name of ThunderFormDC (for IDE apps that are

>running)
>> >or ThunderRT6FormDC (for compiled apps that are running).
>> >
>> >This should discover whether a VB6 app is running, assuming it has a

form
>> >loaded.
>> >
>> >Somehow, I'd like to find something better to use than this, something

>that
>> >would work even if no forms were loaded. However, if no forms were

>loaded,
>> >my usercontrol code wouldn't be executing, so for my immediate needs

this
>> >should work. I just would prefer a cleaner solution.
>> >
>> >Anyone have any ideas?
>> >
>> >
>> >Matthew Cromer

>>
>>

>
>