VB6 - Detecting whether the program is running under the control of Visual Studio or not..
Private Declare Function GetModuleHandle _
Lib "kernel32" Alias _
"GetModuleHandleA" _
(ByVal lpModuleName As String) As Long
Public Function TestEnvironment() As Boolean
Dim ModuleHandle As String
Dim EnvFileName As String
Dim EnvVal As Variant
Dim ReturnVal As Long
Dim i As Long
EnvVal = _
Array("vb.exe", _
"vb32.exe", _
"vb5.exe", _
"vb6.exe")
For i = LBound(EnvVal) To UBound(EnvVal)
ModuleHandle = EnvVal(i)
ReturnVal = GetModuleHandle(ModuleHandle)
If ReturnVal <> 0 Then
EnvFileName = ModuleHandle
TestEnvironment = True
Exit For
End If
Next
End Function
Private Sub Command1_Click()
If TestEnvironment() = True Then
MsgBox ("Running under IDE")
Else
MsgBox ("Running as EXE")
End If
End Sub
Another way to do is to detect whether the Visual Studio 6 IDE open or not using some API.
References Link
Question: How can I test whether a program is running at design time or run time using VB6?
Lib "kernel32" Alias _
"GetModuleHandleA" _
(ByVal lpModuleName As String) As Long
Public Function TestEnvironment() As Boolean
Dim ModuleHandle As String
Dim EnvFileName As String
Dim EnvVal As Variant
Dim ReturnVal As Long
Dim i As Long
EnvVal = _
Array("vb.exe", _
"vb32.exe", _
"vb5.exe", _
"vb6.exe")
For i = LBound(EnvVal) To UBound(EnvVal)
ModuleHandle = EnvVal(i)
ReturnVal = GetModuleHandle(ModuleHandle)
If ReturnVal <> 0 Then
EnvFileName = ModuleHandle
TestEnvironment = True
Exit For
End If
Next
End Function
Private Sub Command1_Click()
If TestEnvironment() = True Then
MsgBox ("Running under IDE")
Else
MsgBox ("Running as EXE")
End If
End Sub
Another way to do is to detect whether the Visual Studio 6 IDE open or not using some API.
References Link
Question: How can I test whether a program is running at design time or run time using VB6?
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home