1 /******************************************************************************
2 *
3 * Copyright (C) 2009, The Gentee Group. All rights reserved.
4 * This file is part of the Gentee open source project - http://www.gentee.com.
5 *
6 * THIS FILE IS PROVIDED UNDER THE TERMS OF THE GENTEE LICENSE ("AGREEMENT").
7 * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE CONSTITUTES RECIPIENTS
8 * ACCEPTANCE OF THE AGREEMENT.
9 *
10 * Author: Alexey Krivonogov ( gentee )
11 *
12 ******************************************************************************/
13
14 import "version.dll"
15 {
16 uint GetFileVersionInfoSizeA( uint, uint ) -> GetFileVersionInfoSize
17 uint GetFileVersionInfoA( uint, uint, uint, uint ) -> GetFileVersionInfo
18 uint VerQueryValueA( uint, uint, uint, uint ) -> VerQueryValue
19 }
20
21 type VS_FIXEDFILEINFO {
22 uint dwSignature
23 uint dwStrucVersion
24 uint dwFileVersionMS
25 uint dwFileVersionLS
26 uint dwProductVersionMS
27 uint dwProductVersionLS
28 uint dwFileFlagsMask
29 uint dwFileFlags
30 uint dwFileOS
31 uint dwFileType
32 uint dwFileSubtype
33 uint dwFileDateMS
34 uint dwFileDateLS
35 }
36
37 func uint getfversion( str filename, uint phiver plowver )
38 {
39 buf data
40 uint off get pvs
41
42 off = GetFileVersionInfoSize( filename.ptr(), &get )
43
44 data.expand( off + 1 )
45 if off && GetFileVersionInfo( filename.ptr(), 0, off, data.ptr() )
46 {
47 // "\\StringFileInfo\\040904E4\\ProductVersion"
48 if VerQueryValue( data.ptr(), "\\".ptr(), &pvs, &get )
49 {
50 phiver->uint = pvs->VS_FIXEDFILEINFO.dwProductVersionMS
51 plowver->uint = pvs->VS_FIXEDFILEINFO.dwProductVersionLS
52 return 1
53 }
54 }
55 return 0
56 }
57
58 method str str.fversion( uint hiver lowver )
59 {
60 return this = "\( hiver >> 16 ).\( hiver & 0xFFFF ).\( lowver >> 16 ).\( lowver & 0xFFFF )"
61 return this
62 }
Редактировать