VBGood网站全文搜索 Google

搜索VBGood全站网页(全文搜索)
首页 - 经验之谈 - 断程式是独立执行还是在VB环境下执行
发表评论(0)作者:不详, 平台:VB6.0+Win98, 阅读:8177, 日期:2001-09-17
断程式是独立执行还是在VB环境下执行


作者: 王国荣 

  此时可呼叫 GetModuleFileName API 函数判断执行档名称是否为 VB5,如果是 VB5, 则GetModuleFileName 最右边的 7 个字元将等於 "VB5.EXE",

Private Declare Function GetModuleFileName Lib "kernel32" Alias _
        "GetModuleFileNameA" (ByVal hModule As Long, ByVal lpFileName As _
        String, ByVal nSize As Long) As Long

Function IsRunUnderVB5() 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)
IsRunUnderVB5 = UCase(Right(S, 7)) = "VB5.EXE"
End Function