Documentation
¶
Overview ¶
Package fileversion provides wrapper for querying properties from windows version-information resource.
fileversion API is aimed to the easiest way of getting file properties so it ignore most of errors querying properties. We suppose most of the time it will be used as "create with New and just access properties". If you need some guaranties - access the properties manually using GetProperty and GetPropertyWithLocale.
For more info about version-information resource look at https://docs.microsoft.com/en-us/windows/win32/menurc/versioninfo-resource
Index ¶
- Constants
- Variables
- type CharsetID
- type FileVersion
- type FixedFileInfo
- type Info
- func (f Info) Comments() string
- func (f Info) CompanyName() string
- func (f Info) FileDescription() string
- func (f Info) FileVersion() string
- func (f Info) FixedInfo() FixedFileInfo
- func (f Info) GetProperty(propertyName string) (string, error)
- func (f Info) GetPropertyWithLocale(propertyName string, locale Locale) (string, error)
- func (f Info) InternalName() string
- func (f Info) LegalCopyright() string
- func (f Info) LegalTrademarks() string
- func (f Info) OriginalFilename() string
- func (f Info) PrivateBuild() string
- func (f Info) ProductName() string
- func (f Info) ProductVersion() string
- func (f Info) SpecialBuild() string
- type LangID
- type Locale
Constants ¶
const ( LangEnglish = LangID(0x049) CSAscii = CharsetID(0x04e4) CSUnicode = CharsetID(0x04B0) CSUnknown = CharsetID(0x0000) )
The package defines a list of most commonly used LangID and CharsetID constant. More combinations you can find in windows docs or at https://godoc.org/github.com/josephspurrier/goversioninfo#pkg-constants
Variables ¶
var DefaultLocales = []Locale{ { LangID: LangEnglish, CharsetID: CSAscii, }, { LangID: LangEnglish, CharsetID: CSUnicode, }, { LangID: LangEnglish, CharsetID: CSUnknown, }, }
DefaultLocales is a list of default Locale values. It's used as a fallback in a calls with automatic locales detection.
Functions ¶
This section is empty.
Types ¶
type CharsetID ¶
type CharsetID uint16
CharsetID is character-set identifier. Could be one of the codes listed in `charsetID` section of https://docs.microsoft.com/en-us/windows/win32/menurc/versioninfo-resource
type FileVersion ¶
FileVersion is a multi-component version.
func (FileVersion) String ¶
func (f FileVersion) String() string
String returns a string representation of the version.
type FixedFileInfo ¶
type FixedFileInfo struct { FileVersion FileVersion ProductVersion FileVersion FileFlagsMask uint32 FileFlags uint32 FileOs uint32 FileType uint32 FileSubType uint32 FileDateMS uint32 FileDateLS uint32 }
FixedFileInfo contains a "fixed" part of a file information (without any strings).
Ref VS_FIXEDFILEINFO: https://docs.microsoft.com/en-us/windows/win32/api/verrsrc/ns-verrsrc-vs_fixedfileinfo
type Info ¶
type Info struct { Locales []Locale // contains filtered or unexported fields }
Info contains a transparent windows object, which is being used for getting file version resource properties.
Locales is a list of locales defined for the object. For the Info created using New it's queried from `\VarFileInfo\Translation`, for ones created using NewWithLocale it's just the given locale.
A translation for the any property value is automatically chosen from Locales and then from fileversion.DefaultLocales prior to to the list order. Use GetPropertyWithLocale for deterministic selection of the property translation.
func New ¶
New creates an Info instance.
It queries a list of translations from the version-information resource and uses them as preferred translations for string properties.
func NewWithLocale ¶
NewWithLocale creates an Info instance with a given locale. All the string properties translations will be firstly queried with the given locale.
See GetPropertyWithLocale for exact properties querying.
func (Info) CompanyName ¶
CompanyName returns CompanyName property.
func (Info) FileDescription ¶
FileDescription returns FileDescription property.
func (Info) FileVersion ¶
FileVersion returns FileVersion property.
func (Info) FixedInfo ¶
func (f Info) FixedInfo() FixedFileInfo
FixedInfo returns a fixed (non-string) part of the file version-information resource. Contains file and product versions.
Ref: https://helloacm.com/c-function-to-get-file-version-using-win32-api-ansi-and-unicode-version/
func (Info) GetProperty ¶
GetProperty queries a string-property from version-information resource.
Single property in a version-information resource can have multiple translations. GetProperty does its best trying to find an existing translation: it returns a first existing translation for any of .Locales and if failed tries to query it for locales from fileversion.DefaultLocales.
func (Info) GetPropertyWithLocale ¶
GetPropertyWithLocale returns string-property with user-defined locale. It's the only way to get the property with the selected translation, all other methods do heuristics in translation choosing.
See Locale, LangID and CharsetID docs for more info about locales.
func (Info) InternalName ¶
InternalName returns InternalName property.
func (Info) LegalCopyright ¶
LegalCopyright returns LegalCopyright property.
func (Info) LegalTrademarks ¶
LegalTrademarks returns LegalTrademarks property.
func (Info) OriginalFilename ¶
OriginalFilename returns OriginalFilename property.
func (Info) PrivateBuild ¶
PrivateBuild returns PrivateBuild property.
func (Info) ProductName ¶
ProductName returns ProductName property.
func (Info) ProductVersion ¶
ProductVersion returns ProductVersion property.
func (Info) SpecialBuild ¶
SpecialBuild returns SpecialBuild property.
type LangID ¶
type LangID uint16
LangID is a Windows language identifier. Could be one of the codes listed in `langID` section of https://docs.microsoft.com/en-us/windows/win32/menurc/versioninfo-resource
type Locale ¶
Locale defines a pair of a language ID and a charsetID. It can be either any combination of predefined LangID and CharsetID or crafted manually suing values from https://docs.microsoft.com/en-us/windows/win32/menurc/versioninfo-resource