Q: How can I Tell whether in Design or Runtime Mode 
Author Message
 Q: How can I Tell whether in Design or Runtime Mode


Quote:
: writes:


:  says:
: >>
: >>Is there a way of telling which mode I am running a VB program. I want
: >>to be able to tell whether the program is running in Design mode or
: >>Runtime mode so that after shelling out, I can AppActivate either
: >>Microsost Visual Basic or my application.
: >
: >You check whether VB.EXE is running using GetModuleUsage.
: >Another trick is then to test the existence of one of your source
: >files on its source directory. A customer would never know that!

Just because VB is running doesn't mean that the app is running under VB.

:     Another way : Put a command line item in the properties dialog of Program
:     Manager for VB icon. Make it a recognizable thing such as VBisrunning. If
:     you are in VB then you will be able to check it using Command$. If you are
:     running the executable it the Command$ returns the actual command line
:     parameters(most of the time it will be empty.)
:         1. Select VB icon in program manager
:         2. Select Properties in the File menu of the PM.
:         3. In command line text box add a string. Make it like;
:                 C:\VB\VB.EXE  VBisrunning
:                 ^^^^^original     ^^^^^^^^added
:         4. Check the command line in your program to see if VBisrunning exists
:            using Command$ statement.

Both of those ways could be easily fooled.  What you do is make an EXE
with a different first 8 characters than the project.  Then you can tell
which is which by the App.EXEName.  The only fool-proof way is to set a
constant in your code.  You have to make sure you change it when you make
the EXE.

Brad
_______________________________________________________________________
 Bradley S. Murray       Princeton Computer Consulting  (609) 799-5300



Mon, 08 Sep 1997 21:19:20 GMT  
 Q: How can I Tell whether in Design or Runtime Mode

Quote:



>: writes:

>:  says:
>: >>
>: >>Is there a way of telling which mode I am running a VB program. I want
>: >>to be able to tell whether the program is running in Design mode or
>: >>Runtime mode so that after shelling out, I can AppActivate either
>: >>Microsost Visual Basic or my application.
>: >

[snip]

Here's some code I use to see if I'm running under VB.

    'flag if running under vb
    Dim te As TASKENTRY
    te.dwSize = Len(te)
    bok% = TaskFindHandle(te, GetCurrentTask())
    If bok% = False Then Exit Sub
    If Left$(te.szModule, 3) = "VB" + Chr$(0) Then DesignEnv = True

Global DesignEnv  As Integer
Type TASKENTRY
    dwSize As Long
    htask As Integer
    hTaskParent As Integer
    hInst As Integer
    hModule As Integer
    wSS As Integer
    wSP As Integer
    wStackTop As Integer
    wStackMinimum As Integer
    wStackBottom As Integer
    wcEvents As Integer
    hQueue As Integer
    szModule As String * 10
    wPSPOffset As Integer
    hNext As Integer
End Type

Declare Function TaskFindHandle Lib "toolhelp.dll" (tent As TASKENTRY, ByVal htask%) As Integer
Declare Function GetCurrentTask Lib "Kernel" () As Integer



Fri, 12 Sep 1997 23:24:42 GMT  
 Q: How can I Tell whether in Design or Runtime Mode


__>Here's some code I use to see if I'm running under VB.
__>

    Even easier, I use OPTIONS, PROJECT an put /debug in the command
line, and then in my init_system routine (Which is called from
form_load) it sets a global variable depending on this, and then
removes it from the command line before anything else sees it.

    Since this will not be passed to the EXE, it works great!

___
* UniQWK #50  * Stay on the road! ** I am! This is a PA road!

== IntJet: QWK, UK, USA, Windows, GUI, OLR, Color, CU 267
'[1;35;40m-=> Delphi Internet Jet SST v3.003B (Beta) - (C) PBE



Sun, 14 Sep 1997 12:16:01 GMT  
 
 [ 3 post ] 

 Relevant Pages 

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

2. HOWTO: Tell Whether an App Runs in VB Design Environment

3. Determine whether running in design mode or not

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

5. Form size changes in runtime vs design time modes

6. Differentiating between Design/Runtime Mode

7. Differentiating between Design/Runtime Modes

8. Best Way to Detect Design-Time vs RunTime Mode of an Applicatin

9. Qs about OO design

10. MainMenu does not show in design mode when Form1.vb[Design] has focus

11. VBE in User Designed Control Design Mode

12. Browser Control: Design Mode vs Compiled Mode

 

 
Powered by phpBB® Forum Software