1
0
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:
dudaodong
2024-10-18 16:38:39 +08:00
parent ed93aae970
commit 0a2cc9c928
10 changed files with 86 additions and 24 deletions

View File

@@ -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
}

View File

@@ -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)
}