新建From1(窗体),新建Command1(按钮CommandButton),代码:
Private Declare Function GetModuleBaseNameA Lib "Psapi.dll" (ByVal hProcess As Long, ByVal hModule As Long, ByVal lpFileName As String, ByVal nSize As Long) As Long
Private Declare Function GetCurrentProcess Lib "kernel32" () As Long
Private Const PROCESS_NAME_MAX_BYTES As Long = 255
Private Property Get IfUsingVB6IDE() As Boolean
Dim ProcessHandle As Long
Dim ProcessName As String
Dim ProcessNameLen As Long
Dim NameBuffer As String * PROCESS_NAME_MAX_BYTES
ProcessHandle = GetCurrentProcess() 'Get Current Process pseudo handle
ProcessNameLen = GetModuleBaseNameA(ProcessHandle, App.hInstance, NameBuffer, PROCESS_NAME_MAX_BYTES) 'Get current Process Base module name (file name)
ProcessName = Left$(NameBuffer, ProcessNameLen) 'clear remaining unused buffer bytes and get only file name
If (UCase$(ProcessName) = "VB6.EXE") Then IfUsingVB6IDE = True 'if current process VB6.exe then we are in VB6 IDE, if else we running as separated process
End Property
Private Sub Command1_Click()
MsgBox IfUsingVB6IDE
End Sub