Just paste this source code into a module called basIDE and include it in your project.
'----------------------------------------------------------------------
'
' Class Name: basIDE
' Written By: C&D Programming Corp.
' Create Date: 6/98
' Copyright: Copyright 1998 by C&D Programming Corp. Source
' code may not be reproduced except for use in a
' compiled executable. All rights reserved. If
' you would like to reprint any or all of this
' code please email us at info@codeoftheweek.com
'----------------------------------------------------------------------
Option Explicit
Private Declare Function GetModuleFileName Lib "kernel32" _
Alias "GetModuleFileNameA" _
(ByVal hModule As Long, _
ByVal lpFileName As String, _
ByVal nSize As Long) As Long
Public Function RunningInIDE() As Boolean
Dim sModuleName As String
Dim lModuleNameLen As Long
On Error GoTo Handler
' pad with NULLs for calling API
sModuleName = String(255, vbNullChar)
' Get EXEcutable filename
lModuleNameLen = GetModuleFileName(App.hInstance, sModuleName, 255)
' Get everything returned except for the NULL
sModuleName = Left$(sModuleName, lModuleNameLen)
' Check to see if the filename is VB5.EXE. This will not work if the end-user
' has renamed their copy of Visual Basic (which should be unusual).
' It should work the same in VB4, just change the EXE name to be the
' VB4 exe name.
If LCase$(Right(sModuleName, 7)) <> "vb5.exe" Then
RunningInIDE = False
Else
RunningInIDE = True
End If
Exit Function
Handler:
Err.Raise Err.Number, "RunningInIDE", Err.Description
End Function