Re: Setting the build number in VB6




"Dermot Hardy" <dermot_hardy@xxxxxxxxxxx> wrote in message
news:OgHEMT8gFHA.2152@xxxxxxxxxxxxxxxxxxxxxxx
> Hi,
>
> Does anyone know a way to set the 3rd version number in VB6? It seems VB6
> always uses major.minor.0.revision. Unfortunatly I need to use the third
> number as the build number so that I can use the forth number for patches.
> Does anyone know how this can be achieved?


VB does not support a 4th part of the version number. As Ken suggested, you
can use tools like vbAdvance. Another way to modify the version number
would be to open your EXE (or DLL, OCX) in VC++ and edit the Version
resource (change the "FILEVERSION"). Also, you would only be able to do it
this way under NT-based versions of Windows because Win9x lacks the API
functions for updating resources.

Keep in mind that there's still nothing provided in VB for getting all 4
parts of the version number (as the App object still only has properties for
3 of these). You would have obtain the version number using the Win32API.
Here's code for that:

-----BEGIN CODE

Private Type VERINFO 'Version FIXEDFILEINFO
strPad1 As Long 'Pad out struct version
strPad2 As Long 'Pad out struct signature
nMSLo As Integer 'Low word of ver # MS DWord
nMSHi As Integer 'High word of ver # MS DWord
nLSLo As Integer 'Low word of ver # LS DWord
nLSHi As Integer 'High word of ver # LS DWord
strPad3(1 To 16) As Byte 'Skip some of VERINFO struct (16 bytes)
FileOS As Long 'Information about the OS this file is
targeted for.
strPad4(1 To 16) As Byte 'Pad out the rest of VERINFO struct (16
bytes)
End Type

Private Declare Function GetFileVersionInfoSize Lib "VERSION.DLL" Alias
"GetFileVersionInfoSizeA" (ByVal sFileName As String, lVerHandle As Long) As
Long

Private Declare Function GetFileVersionInfo Lib "VERSION.DLL" Alias
"GetFileVersionInfoA" (ByVal sFileName As String, ByVal lVerHandle As Long,
ByVal lcbSize As Long, lpvData As Byte) As Long

Private Declare Function VerQueryValue Lib "VERSION.DLL" Alias
"VerQueryValueA" (lpvVerData As Byte, ByVal lpszSubBlock As String, lplpBuf
As Long, lpcb As Long) As Long

Private Function GetVersionString(ByVal sFileName As String, ByRef
udtVerInfo As VERINFO) As String

'This function is based on code found in SETUP1.VBP.
'Some variable names were changed and unnecessary code was removed.

'It obtains the internal file version number for the passed file,
formats
'it into a string, and then returns that string. The VERINFO structure
'will be filled with the version information.

Dim sVersion As String

If FileExists(sFileName) = False Then
GetVersionString = ""
Exit Function
End If

On Error GoTo GFVError

'Get the file version into a VERINFO struct, and then assemble a version
string
'from the appropriate elements.
If GetFileVerStruct(sFileName, udtVerInfo) = True Then
sVersion = Format$(udtVerInfo.nMSHi) & "." &
Format$(udtVerInfo.nMSLo) & "."
sVersion = sVersion & Format$(udtVerInfo.nLSHi) & "." &
Format$(udtVerInfo.nLSLo)
GetVersionString = sVersion
Else
GetVersionString = ""
End If

Exit Function

GFVError:
GetVersionString = ""

End Function

-----END CODE

--
Mike
Microsoft MVP Visual Basic


.



Relevant Pages

  • Re: CryptAPI
    ... > Private Declare Function CryptAcquireContext Lib "advapi32.dll" Alias ... > As String, ByVal dwProvType As Long, ByVal dwFlags As Long) As Long ... > On Error GoTo ErrSign ...
    (microsoft.public.vb.winapi)
  • Re: problem with RegQueryValueEx (long)
    ... >> Function RegGetString(hInKey As Long, ByVal sSubKey As String, ByVal ... > (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long ... > Private Declare Function RegCreateKeyEx Lib "advapi32.dll" Alias ...
    (microsoft.public.vb.general.discussion)
  • Re: Need to call windows scheduler.
    ... Private Declare Function OpenSCManager Lib "advapi32.dll" Alias ... "OpenSCManagerA" (ByVal lpMachineName As String, ... Dim lhSCM As Long, lhService As Long, sState As String, lReturn ...
    (microsoft.public.access.formscoding)
  • Re: Message or input
    ... Private Declare Function GetCurrentThreadId Lib "kernel32" _ ... ByVal lpCaption As String, _ ... Dim mbFlags2 As VbMsgBoxStyle ... SetDlgItemText wParam, vbAbort, But1 ...
    (microsoft.public.excel.misc)
  • Re: Weird AddIn behaviour
    ... Private Declare Function RegCreateKeyEx Lib "advapi32.dll" Alias ... "RegCreateKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ... Do While Not (strValue = "Not Found") ...
    (microsoft.public.excel.programming)

Loading