How to determine if the program is running in VB-environment or as standalone EXE?



    In 16 bit environments this works:

    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 GetCurrentTask% Lib "Kernel" ()
    Declare Function TaskFindHandle% Lib "Toolhelp" (lpte As TASKENTRY,
    ByVal hTask%)
    
    Function VBDesignEnvironment% ()
    ' Author: Mag
    Article
    ' Return: True if running in the VB design time environment
      Dim TE As TASKENTRY, hTask%, r%
    
      hTask% = GetCurrentTask%()
      TE.dwSize = Len(TE)
      r% = TaskFindHandle(TE, hTask%)
      VBDesignEnvironment% = ("VB" = Left(TE.szModule, InStr(TE.szModule,
    Chr(0)) - 1))
    
    End Function
    

Mail to Daniel Wiman <daniel@wimania.com>
Online since June 1996, updated 971025
<- The VB home
<- Daniels homepage