第1个回答 2012-06-04
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, Length
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 Form_Load()
If IsRunUnderVB6 = False Then MsgBox "错误": Unload Me
End Sub
在vb环境下运行和生成exe后运行之间看看有没有区别