forked from nsf/gocode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathos_win32.go
More file actions
34 lines (30 loc) · 770 Bytes
/
os_win32.go
File metadata and controls
34 lines (30 loc) · 770 Bytes
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
package main
import (
"flag"
"fmt"
"os"
"syscall"
"unsafe"
"utf16"
)
func CreateSockFlag(name, desc string) *string {
return flag.String(name, "tcp", desc)
}
func IsTerminationSignal(sig os.Signal) bool {
return false
}
// Full path of the current executable
func GetExecutableFileName() string {
kernel32, _ := syscall.LoadLibrary("kernel32.dll")
defer syscall.FreeLibrary(kernel32)
b := make([]uint16, syscall.MAX_PATH)
getModuleFileName, _ := syscall.GetProcAddress(kernel32, "GetModuleFileNameW")
ret, _, callErr := syscall.Syscall(uintptr(getModuleFileName),
3, 0,
uintptr(unsafe.Pointer(&b[0])),
uintptr(len(b)))
if callErr != 0 {
panic(fmt.Sprintf("GetModuleFileNameW : err %d", int(callErr)))
}
return string(utf16.Decode(b[:ret]))
}