This repository has been archived by the owner on Jan 22, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
/
version.go
95 lines (83 loc) · 2.87 KB
/
version.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
// This file was automatically generated by https://github.com/kbinani/win/blob/generator/internal/cmd/gen/gen.go
// go run internal/cmd/gen/gen.go
// +build windows
package win
import (
"unsafe"
)
var (
// Library
libversion uintptr
// Functions
getFileVersionInfoSize uintptr
getFileVersionInfo uintptr
verFindFile uintptr
verInstallFile uintptr
verQueryValue uintptr
)
func init() {
// Library
libversion = doLoadLibrary("version.dll")
// Functions
getFileVersionInfoSize = doGetProcAddress(libversion, "GetFileVersionInfoSizeW")
getFileVersionInfo = doGetProcAddress(libversion, "GetFileVersionInfoW")
verFindFile = doGetProcAddress(libversion, "VerFindFileW")
verInstallFile = doGetProcAddress(libversion, "VerInstallFileW")
verQueryValue = doGetProcAddress(libversion, "VerQueryValueW")
}
func GetFileVersionInfoSize(lptstrFilename string, lpdwHandle *uint32) DWORD {
lptstrFilenameStr := unicode16FromString(lptstrFilename)
ret1 := syscall3(getFileVersionInfoSize, 2,
uintptr(unsafe.Pointer(&lptstrFilenameStr[0])),
uintptr(unsafe.Pointer(lpdwHandle)),
0)
return DWORD(ret1)
}
func GetFileVersionInfo(lptstrFilename string, dwHandle DWORD, dwLen DWORD, lpData LPVOID) bool {
lptstrFilenameStr := unicode16FromString(lptstrFilename)
ret1 := syscall6(getFileVersionInfo, 4,
uintptr(unsafe.Pointer(&lptstrFilenameStr[0])),
uintptr(dwHandle),
uintptr(dwLen),
uintptr(unsafe.Pointer(lpData)),
0,
0)
return ret1 != 0
}
func VerFindFile(uFlags DWORD, szFileName LPWSTR, szWinDir LPWSTR, szAppDir LPWSTR, szCurDir LPWSTR, lpuCurDirLen *uint32, szDestDir LPWSTR, lpuDestDirLen *uint32) DWORD {
ret1 := syscall9(verFindFile, 8,
uintptr(uFlags),
uintptr(unsafe.Pointer(szFileName)),
uintptr(unsafe.Pointer(szWinDir)),
uintptr(unsafe.Pointer(szAppDir)),
uintptr(unsafe.Pointer(szCurDir)),
uintptr(unsafe.Pointer(lpuCurDirLen)),
uintptr(unsafe.Pointer(szDestDir)),
uintptr(unsafe.Pointer(lpuDestDirLen)),
0)
return DWORD(ret1)
}
func VerInstallFile(uFlags DWORD, szSrcFileName LPWSTR, szDestFileName LPWSTR, szSrcDir LPWSTR, szDestDir LPWSTR, szCurDir LPWSTR, szTmpFile LPWSTR, lpuTmpFileLen *uint32) DWORD {
ret1 := syscall9(verInstallFile, 8,
uintptr(uFlags),
uintptr(unsafe.Pointer(szSrcFileName)),
uintptr(unsafe.Pointer(szDestFileName)),
uintptr(unsafe.Pointer(szSrcDir)),
uintptr(unsafe.Pointer(szDestDir)),
uintptr(unsafe.Pointer(szCurDir)),
uintptr(unsafe.Pointer(szTmpFile)),
uintptr(unsafe.Pointer(lpuTmpFileLen)),
0)
return DWORD(ret1)
}
func VerQueryValue(pBlock /*const*/ LPVOID, lpSubBlock string, lplpBuffer *LPVOID, puLen *uint32) bool {
lpSubBlockStr := unicode16FromString(lpSubBlock)
ret1 := syscall6(verQueryValue, 4,
uintptr(unsafe.Pointer(pBlock)),
uintptr(unsafe.Pointer(&lpSubBlockStr[0])),
uintptr(unsafe.Pointer(lplpBuffer)),
uintptr(unsafe.Pointer(puLen)),
0,
0)
return ret1 != 0
}