mirror of
https://github.com/duke-git/lancet.git
synced 2026-02-04 12:52:28 +08:00
doc: update doc for RandNumberOfLength and GetExeOrDllVersion
This commit is contained in:
@@ -25,8 +25,9 @@ type tagVS_FIXEDFILEINFO struct {
|
||||
FileDateLS uint32
|
||||
}
|
||||
|
||||
// GetExeDllVersion 获取exe或dll文件的版本信息
|
||||
func GetExeDllVersion(filePath string) (string, error) {
|
||||
// GetExeOrDllVersion get the version of exe or dll file on windows.
|
||||
// Play: todo
|
||||
func GetExeOrDllVersion(filePath string) (string, error) {
|
||||
// 加载系统dll
|
||||
versionDLL := syscall.NewLazyDLL("version.dll")
|
||||
getFileVersionInfoSize := versionDLL.NewProc("GetFileVersionInfoSizeW")
|
||||
@@ -77,5 +78,6 @@ func GetExeDllVersion(filePath string) (string, error) {
|
||||
minor := fixedInfo.FileVersionMS & 0xFFFF
|
||||
build := fixedInfo.FileVersionLS >> 16
|
||||
revision := fixedInfo.FileVersionLS & 0xFFFF
|
||||
|
||||
return fmt.Sprintf("%d.%d.%d.%d", major, minor, build, revision), nil
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@ package fileutil
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestGetExeDllVersion(t *testing.T) {
|
||||
v, err := GetExeDllVersion(`C:\Windows\System32\cmd.exe`)
|
||||
func TestGetExeOrDllVersion(t *testing.T) {
|
||||
v, err := GetExeOrDllVersion(`C:\Windows\System32\cmd.exe`)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user