vb做的软件如何获得自己的版本号?
2个回答
展开全部
如果你用的是vb6,而且指的是你在编译程序的时候写的版本号,比如1.0.1可以用app的属性得到
MsgBox App.Major & "." & App.Minor & "." & App.Revision
其中major是主版本,minor是次版本,revision是修正
在.net中会比较麻烦点,参考下面
Type FileInfo
wLength As Integer
wValueLength As Integer
szKey As String * 16
dwSignature As Long
dwStrucVersion As Long
dwFileVersionMS As Long
dwFileVersionLS As Long
End Type
' NOTE: The following Declare statements are case sensitive.
Declare Function GetFileVersionInfo& Lib "Version" _
Alias "GetFileVersionInfoA" (ByVal FileName$, _
ByVal dwHandle&, ByVal cbBuff&, ByVal lpvData$)
Declare Function GetFileVersionInfoSize& Lib "Version" Alias _
"GetFileVersionInfoSizeA" (ByVal FileName$, dwHandle&)
Declare Sub hmemcpy Lib "Kernel32" Alias "RtlMoveMemory" _
(hpvDest As Any, hpvSource As Any, ByVal cbBytes&)
Function LOWORD(x As Long) As Integer
LOWORD = x And &HFFFF&
' Low 16 bits contain Minor revision number.
End Function
Function HIWORD(x As Long) As Integer
HIWORD = x \ &HFFFF&
' High 16 bits contain Major revision number.
End Function
'----------------------------------------
'以下为执行模块,在 VBE 界面按 F5 执行
'----------------------------------------
Function displayVersion()
Dim x As FileInfo
Dim FileVer As String
Dim FileName As String
Dim dwHandle&, BufSize&, lpvData$, R&
'*** Get Version Information If Available ****
FileVer = ""
'FileName = 路径
FileName = Environ("windir") & "\system32\msjet40.dll"
BufSize& = GetFileVersionInfoSize(FileName, dwHandle&)
If BufSize& = 0 Then
MsgBox "Invalid File Name or no Version information available"
Exit Function
End If
lpvData$ = Space$(BufSize&)
R& = GetFileVersionInfo(FileName, dwHandle&, BufSize&, lpvData$)
hmemcpy x, ByVal lpvData$, Len(x)
'**** Parse File Version Number ****
FileVer = Trim$(Str$(HIWORD(x.dwFileVersionMS))) + "."
FileVer = FileVer + Trim$(Str$(LOWORD(x.dwFileVersionMS))) + "."
FileVer = FileVer + Trim$(Str$(HIWORD(x.dwFileVersionLS))) + "."
FileVer = FileVer + Trim$(Str$(LOWORD(x.dwFileVersionLS)))
MsgBox FileVer, 64, "Version of " & FileName
End Function
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/Luckeryin/archive/2008/11/10/3269417.aspx
MsgBox App.Major & "." & App.Minor & "." & App.Revision
其中major是主版本,minor是次版本,revision是修正
在.net中会比较麻烦点,参考下面
Type FileInfo
wLength As Integer
wValueLength As Integer
szKey As String * 16
dwSignature As Long
dwStrucVersion As Long
dwFileVersionMS As Long
dwFileVersionLS As Long
End Type
' NOTE: The following Declare statements are case sensitive.
Declare Function GetFileVersionInfo& Lib "Version" _
Alias "GetFileVersionInfoA" (ByVal FileName$, _
ByVal dwHandle&, ByVal cbBuff&, ByVal lpvData$)
Declare Function GetFileVersionInfoSize& Lib "Version" Alias _
"GetFileVersionInfoSizeA" (ByVal FileName$, dwHandle&)
Declare Sub hmemcpy Lib "Kernel32" Alias "RtlMoveMemory" _
(hpvDest As Any, hpvSource As Any, ByVal cbBytes&)
Function LOWORD(x As Long) As Integer
LOWORD = x And &HFFFF&
' Low 16 bits contain Minor revision number.
End Function
Function HIWORD(x As Long) As Integer
HIWORD = x \ &HFFFF&
' High 16 bits contain Major revision number.
End Function
'----------------------------------------
'以下为执行模块,在 VBE 界面按 F5 执行
'----------------------------------------
Function displayVersion()
Dim x As FileInfo
Dim FileVer As String
Dim FileName As String
Dim dwHandle&, BufSize&, lpvData$, R&
'*** Get Version Information If Available ****
FileVer = ""
'FileName = 路径
FileName = Environ("windir") & "\system32\msjet40.dll"
BufSize& = GetFileVersionInfoSize(FileName, dwHandle&)
If BufSize& = 0 Then
MsgBox "Invalid File Name or no Version information available"
Exit Function
End If
lpvData$ = Space$(BufSize&)
R& = GetFileVersionInfo(FileName, dwHandle&, BufSize&, lpvData$)
hmemcpy x, ByVal lpvData$, Len(x)
'**** Parse File Version Number ****
FileVer = Trim$(Str$(HIWORD(x.dwFileVersionMS))) + "."
FileVer = FileVer + Trim$(Str$(LOWORD(x.dwFileVersionMS))) + "."
FileVer = FileVer + Trim$(Str$(HIWORD(x.dwFileVersionLS))) + "."
FileVer = FileVer + Trim$(Str$(LOWORD(x.dwFileVersionLS)))
MsgBox FileVer, 64, "Version of " & FileName
End Function
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/Luckeryin/archive/2008/11/10/3269417.aspx
参考资料: http://blog.csdn.net/Luckeryin/archive/2008/11/10/3269417.aspx
AiPPT
2024-09-19 广告
2024-09-19 广告
作为北京饼干科技有限公司的工作人员,关于AIPPT免费生成PPT的功能,我可以简要介绍如下:AIPPT是一款基于人工智能技术的PPT制作工具,它为用户提供了免费生成PPT的便捷服务。用户只需简单输入PPT的主题或内容大纲,AIPPT便能智能...
点击进入详情页
本回答由AiPPT提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询