-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathgdi32.go
More file actions
55 lines (43 loc) · 1.03 KB
/
gdi32.go
File metadata and controls
55 lines (43 loc) · 1.03 KB
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
package main
import (
"log"
"syscall"
"unsafe"
"golang.org/x/sys/windows"
)
var (
// Library
libgdi32 *windows.LazyDLL
// Functions
getFontResourceInfoW *windows.LazyProc
)
func init() {
// Library
libgdi32 = windows.NewLazySystemDLL("gdi32.dll")
// Functions
getFontResourceInfoW = libgdi32.NewProc("GetFontResourceInfoW")
}
func GetFontResourceInfoW(str string, size *uint32, buffer uintptr, aType int) bool { // DWORD
strStr, err := windows.UTF16FromString(str)
if err != nil {
log.Println(err)
}
ret1, _, _ := syscall.SyscallN(getFontResourceInfoW.Addr(),
uintptr(unsafe.Pointer(&strStr[0])),
uintptr(unsafe.Pointer(size)),
buffer,
uintptr(aType))
return ret1 != 0
}
const QFR_DESCRIPTION = 1
func GetFontResourceInfo(font string) string {
var size uint32 = 0
if !GetFontResourceInfoW(font, &size, 0, QFR_DESCRIPTION) {
return ""
}
buff := make([]uint16, size/2)
if GetFontResourceInfoW(font, &size, uintptr(unsafe.Pointer(&buff[0])), QFR_DESCRIPTION) {
return syscall.UTF16ToString(buff)
}
return ""
}