Skip to content

Commit f2add59

Browse files
committedMar 3, 2019
change variable initialization logic
1 parent 1caf4d4 commit f2add59

File tree

2 files changed

+3
-19
lines changed

2 files changed

+3
-19
lines changed
 

‎examples/syscall/lasterror/syscall.go

+2-12
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,13 @@ import (
77
)
88

99
var (
10-
libuser32 *windows.LazyDLL
11-
libkernel32 *windows.LazyDLL
10+
libuser32 = windows.NewLazySystemDLL("user32.dll")
1211

13-
procMessageBoxW *windows.LazyProc
14-
procGetLastError *windows.LazyProc
12+
procMessageBoxW = libuser32.NewProc("MessageBoxW")
1513

1614
lastError error
1715
)
1816

19-
func init() {
20-
libuser32 = windows.NewLazySystemDLL("user32.dll")
21-
libkernel32 = windows.NewLazySystemDLL("kernel32.dll")
22-
23-
procMessageBoxW = libuser32.NewProc("MessageBoxW")
24-
procGetLastError = libkernel32.NewProc("GetLastError")
25-
}
26-
2717
func messageBox(hWnd uintptr, lpText *uint16, lpCaption *uint16, uType uint32) int32 {
2818
var r1 uintptr
2919
r1, _, lastError = procMessageBoxW.Call(hWnd, uintptr(unsafe.Pointer(lpText)), uintptr(unsafe.Pointer(lpCaption)), uintptr(uType))

‎examples/syscall/module/syscall.go

+1-7
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,10 @@ import (
77
)
88

99
var (
10-
libuser32 *windows.LazyDLL
11-
12-
procMessageBoxW *windows.LazyProc
13-
)
14-
15-
func init() {
1610
libuser32 = windows.NewLazySystemDLL("user32.dll")
1711

1812
procMessageBoxW = libuser32.NewProc("MessageBoxW")
19-
}
13+
)
2014

2115
func messageBox(hWnd uintptr, lpText *uint16, lpCaption *uint16, uType uint32) int32 {
2216
r1, _, _ := procMessageBoxW.Call(hWnd, uintptr(unsafe.Pointer(lpText)), uintptr(unsafe.Pointer(lpCaption)), uintptr(uType))

0 commit comments

Comments
 (0)