Try
創(chuàng)新互聯(lián)公司成立與2013年,先為環(huán)江等服務(wù)建站,環(huán)江等地企業(yè),進(jìn)行企業(yè)商務(wù)咨詢服務(wù)。為環(huán)江企業(yè)網(wǎng)站制作PC+手機(jī)+微官網(wǎng)三網(wǎng)同步一站式服務(wù)解決您的所有建站問(wèn)題。
Me.Text = "版本V" Deployment.Application.ApplicationDeployment.CurrentDeployment.CurrentVersion.ToString()
Catch ex As Exception
Me.Text = "未知版本"
End Try
這個(gè)你把1.0.2.3這個(gè)字符串處理下就可以了。
這個(gè)屬于字符串的處理
如果你用的是vb6,而且指的是你在編譯程序的時(shí)候?qū)懙陌姹咎?hào),比如1.0.1可以用app的屬性得到
MsgBox App.Major "." App.Minor "." App.Revision
其中major是主版本,minor是次版本,revision是修正
在.net中會(huì)比較麻煩點(diǎn),參考下面
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
'----------------------------------------
'以下為執(zhí)行模塊,在 VBE 界面按 F5 執(zhí)行
'----------------------------------------
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
本文來(lái)自CSDN博客,轉(zhuǎn)載請(qǐng)標(biāo)明出處: