Module cVersionInfo.pkg
1// Class cVersionInfo
2//
3// Stores version information about the EXE
4// Designed to be instantiated as a child of the Application object
5//
6// Created: Mar 12, 2002 SWB
7
8
9Use Windows.pkg
10Use DLL.pkg
11Use WinKern.pkg
12
13Define VS_FF_DEBUG for |CI$00000001
14Define VS_FF_PRERELEASE for |CI$00000002
15Define VS_FF_PATCHED for |CI$00000004
16Define VS_FF_PRIVATEBUILD for |CI$00000008
17Define VS_FF_INFOINFERRED for |CI$00000010
18Define VS_FF_SPECIALBUILD for |CI$00000020
19
20External_Function GetFileVersionInfoSize "GetFileVersionInfoSizeA" version.dll ;
21 Pointer aFilename ;
22 Pointer lpdwHandle ;
23Returns Dword
24
25External_Function GetFileVersionInfo "GetFileVersionInfoA" version.dll ;
26 Pointer sFilename ;
27 Dword dwHandle ;
28 Dword dwLen ;
29 Address aData ;
30Returns Integer
31
32External_Function VerQueryValue "VerQueryValueA" version.dll ;
33 Address aBlock ;
34 Address aSubBlock ;
35 Address aaBuffer ;
36 Address puLen ;
37Returns Integer
38
39Type tVsFixedFileInfo
40 Field tVsFixedFileInfo.dwSignature as Dword
41 Field tVsFixedFileInfo.dwStrucVersion as Dword
42 Field tVsFixedFileInfo.dwFileVersionMS as Dword
43 Field tVsFixedFileInfo.dwFileVersionLS as Dword
44 Field tVsFixedFileInfo.dwProductVersionMS as Dword
45 Field tVsFixedFileInfo.dwProductVersionLS as Dword
46 Field tVsFixedFileInfo.dwFileFlagsMask as Dword
47 Field tVsFixedFileInfo.dwFileFlags as Dword
48 Field tVsFixedFileInfo.dwFileOS as Dword
49 Field tVsFixedFileInfo.dwFileType as Dword
50 Field tVsFixedFileInfo.dwFileSubtype as Dword
51 Field tVsFixedFileInfo.dwFileDateMS as Dword
52 Field tVsFixedFileInfo.dwFileDateLS as Dword
53End_Type
54
55{ ClassLibrary=Common }
56{ HelpTopic=cVersionInfo }
57Class cVersionInfo is a cObject
58 Procedure Construct_Object
59 Forward Send Construct_Object
60
61
62 Property Integer piVersionMajor
63 Property Integer piVersionMinor
64 Property Integer piVersionRelease
65 Property Integer piVersionBuild
66
67 Property Boolean pbIncluded
68 Property Boolean pbSpecialBuild
69 Property Boolean pbPrivateBuild
70
71 End_Procedure
72
73 Procedure DoCreate String sFileName
74 Dword dwHandle
75 Integer iInfoSize iVerSize iSuccess iVersion iVoid iFlags
76 String sData
77 String sVersionBuffer
78 String sVsFixedFileInfo
79 String sSubBlock
80 Address aVsFixedFileInfo
81
82 move 0 To aVsFixedFileInfo
83 Move 0 To dwHandle
84 Move 0 To iVerSize
85
86 Move (GetFileVersionInfoSize(AddressOf(sFilename), AddressOf(dwHandle))) To iInfoSize
87 Set pbIncluded To (iInfoSize <>0)
88
89 If (pbIncluded(self)) Begin
90 Move (Repeat(Character(0), iInfoSize)) To sData
91 Move (GetFileVersionInfo(AddressOf(sFilename), 0, iInfoSize, AddressOf(sData))) To iSuccess
92
93 If (iSuccess <>0) Begin
94 Move "\" To sSubBlock
95 If (VerQueryValue(AddressOf(sData), AddressOf(sSubBlock), AddressOf(aVsFixedFileInfo), AddressOf(iVerSize))) Begin
96 ZeroType tVsFixedFileInfo To sVsFixedFileInfo
97 Move (memcopy(AddressOf(sVsFixedFileInfo), aVsFixedFileInfo, iVerSize)) to iVoid // copy the structure
98
99 GetBuff from sVsFixedFileInfo at tVsFixedFileInfo.dwFileVersionMS To iVersion
100 Set piVersionMajor To (Hi(iVersion))
101 Set piVersionMinor To (Low(iVersion))
102
103 GetBuff from sVsFixedFileInfo at tVsFixedFileInfo.dwFileVersionLS To iVersion
104 Set piVersionRelease To (Hi(iVersion))
105 Set piVersionBuild To (Low(iVersion))
106
107 GetBuff from sVsFixedFileInfo at tVsFixedFileInfo.dwFileFlags To iFlags
108 Set pbSpecialBuild To (iFlags IAND VS_FF_SPECIALBUILD)
109 Set pbPrivateBuild To (iFlags IAND VS_FF_PRIVATEBUILD)
110 End
111 End
112
113 End
114 End_Procedure
115
116End_Class
117
118
119