by L. F. Carpenter (2 Submissions)
Category: Windows API Call/Explanation
Compatability: Visual Basic 3.0
Difficulty: Intermediate
Date Added: Wed 3rd February 2021
Rating:
(3 Votes)
This function will return whether you are running your program or DLL from within the IDE, or compiled. I use it as part of my DLL's like active document DLL's to setup information that would normally be supplied from the outside.
Code Returns
Returns True if you are running inside the VB 5.0 or 6.0 IDE.
API DeclarationsPrivate Declare Function GetModuleFileName Lib "kernel32" _
Alias "GetModuleFileNameA" _
( _
ByVal hModule As Long, _
ByVal lpFileName As String, _
ByVal nSize As Long _
) As Long
Public Function InVBDesignEnvironment() As Boolean
Dim strFileName As String
Dim lngCount As Long
strFileName = String(255, 0)
lngCount = GetModuleFileName(App.hInstance, strFileName, 255)
strFileName = Left(strFileName, lngCount)
InVBDesignEnvironment = False
If UCase(Right(strFileName, 7)) = "VB5.EXE" Then
InVBDesignEnvironment = True
ElseIf UCase(Right(strFileName, 7)) = "VB6.EXE" Then
InVBDesignEnvironment = True
End If
End Function