VB中新建工程,添加一个按钮。 使用的时候,在IDE环境下F5运行和编译后运行就可以看到效果。 Option Explicit ? Private Declare Function GetModuleFileName Lib "kernel32" Alias _ ??????? "GetModuleFileNameA" (ByVal hModule As Long, ByVal lpFileName As _ ??????? String, ByVal nSize As Long) As Long ? Function IsRunUnderVB6() As Boolean ?Dim S As String ?Dim Length As Long ?Length = 256 ?S = String(Length, 0) ?Call GetModuleFileName(0, S, Length) ?S = Left(S, InStr(S, Chr(0)) - 1) ?IsRunUnderVB6 = UCase(Right(S, 7)) = "VB6.EXE" End Function ? Private Sub Command1_Click() If IsRunUnderVB6 Then MsgBox "调试" Else MsgBox "运行" End If End Sub |