
Q: How can I Tell whether in Design or Runtime Mode
Quote:
>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.
Unfortunately, App.EXEName doesn't really return the name of the currently
running program when in design mode, so you have to fiddle with API calls to
get it.
First, copy the declarations of GetWindowWord, GetInstanceModule,
GetModuleFileName and GWW_HInstance from the API help file or win30api.txt.
Next, use the following code to get the EXE file name. If you're running in
design mode, it's VB.EXE; otherwise it isn't (unless you've called your
program VB :-)):
Inst% = GetWindowWord(MasterForm.hWnd, GWW_Hinstance)
'Where "MasterForm" is the main (or any open) form in your app.
Inst% = GetInstanceModule(Inst%)
'Probably not necessary. Anyone care to enlighten me?
res% = GetModuleFileName(Inst%, Windir, Len(Windir))
If InStr(Left(Windir, res%), "VB.EXE") Then
MsgBox "Design Mode"
Else
MsgBox "Runtime"
End If