github.com/hy3/cuto@v0.9.8-0.20160830082821-aa6652f877b7/util/syscall_windows.go (about) 1 // Copyright 2015 unirita Inc. 2 // Created 2015/04/10 shanxia 3 4 package util 5 6 import ( 7 "syscall" 8 ) 9 10 // DLLハンドル 11 type cutoDLL struct { 12 dll *syscall.DLL 13 } 14 15 var ( 16 kernel32_dll = loadDLL("kernel32.dll") 17 18 procCreateMutexW = kernel32_dll.findProc("CreateMutexW") 19 procWaitForSingleObject = kernel32_dll.findProc("WaitForSingleObject") 20 procReleaseMutex = kernel32_dll.findProc("ReleaseMutex") 21 procCloseHandle = kernel32_dll.findProc("CloseHandle") 22 procGetModuleFileNameW = kernel32_dll.findProc("GetModuleFileNameW") 23 // WindowsAPIの関数アドレスはここに追加してください。 24 ) 25 26 func loadDLL(name string) *cutoDLL { 27 dll, err := syscall.LoadDLL(name) 28 if err != nil { 29 panic(err) 30 } 31 cutoDll := new(cutoDLL) 32 cutoDll.dll = dll 33 return cutoDll 34 } 35 36 func (c *cutoDLL) findProc(name string) *syscall.Proc { 37 proc, err := c.dll.FindProc(name) 38 if err != nil { 39 panic(err) 40 } 41 return proc 42 }