Ai
1 Star 0 Fork 0

略过寒冬/go-winapi

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
winapi.go 1.80 KB
一键复制 编辑 原始数据 按行查看 历史
// Copyright 2010 The Walk Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package winapi
import (
"fmt"
"syscall"
"unsafe"
)
const (
S_OK = 0x00000000
S_FALSE = 0x00000001
E_UNEXPECTED = 0x8000FFFF
E_NOTIMPL = 0x80004001
E_OUTOFMEMORY = 0x8007000E
E_INVALIDARG = 0x80070057
E_NOINTERFACE = 0x80004002
E_POINTER = 0x80004003
E_HANDLE = 0x80070006
E_ABORT = 0x80004004
E_FAIL = 0x80004005
E_ACCESSDENIED = 0x80070005
E_PENDING = 0x8000000A
)
const (
FALSE = 0
TRUE = 1
)
type (
BOOL int32
HRESULT uint32
)
type GUID struct {
Data1 uint32
Data2 uint16
Data3 uint16
Data4 [8]byte
}
func MustLoadLibrary(name string) uintptr {
lib, errno := syscall.LoadLibrary(name)
if errno != 0 {
panic(fmt.Sprintf(`syscall.LoadLibrary("%s") failed: %s`, name, syscall.Errstr(errno)))
}
return uintptr(lib)
}
func MustGetProcAddress(lib uintptr, name string) uintptr {
addr, errno := syscall.GetProcAddress(syscall.Handle(lib), name)
if errno != 0 {
panic(fmt.Sprintf(`syscall.GetProcAddress(%d, "%s") failed: %s`, lib, name, syscall.Errstr(errno)))
}
return uintptr(addr)
}
func SUCCEEDED(hr HRESULT) bool {
return hr >= 0
}
func FAILED(hr HRESULT) bool {
return hr < 0
}
func MAKELONG(lo, hi uint16) uint32 {
return uint32(uint32(lo) | ((uint32(hi)) << 16))
}
func LOWORD(dw uint32) uint16 {
return uint16(dw)
}
func HIWORD(dw uint32) uint16 {
return uint16(dw >> 16 & 0xffff)
}
func UTF16PtrToString(s *uint16) string {
return syscall.UTF16ToString((*[1 << 30]uint16)(unsafe.Pointer(s))[0:])
}
func MAKEINTRESOURCE(id uintptr) *uint16 {
return (*uint16)(unsafe.Pointer(id))
}
func BoolToBOOL(value bool) BOOL {
if value {
return 1
}
return 0
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/skip-the-cold-winter/go-winapi.git
git@gitee.com:skip-the-cold-winter/go-winapi.git
skip-the-cold-winter
go-winapi
go-winapi
8d5f10e8e797

搜索帮助