|
|
|
@ -215,16 +215,35 @@ func GetClipboardOwner() (HWND, error) {
|
|
|
|
|
return HWND(r), nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func GetUpdatedClipboardFormats() ([]DWORD, error) {
|
|
|
|
|
var formats []DWORD
|
|
|
|
|
for i := 0; ; i++ {
|
|
|
|
|
format, err := EnumClipboardFormats(DWORD(i))
|
|
|
|
|
func GetUpdatedClipboardFormats(lpuiFormats unsafe.Pointer, cFormats int, pcFormats unsafe.Pointer) (int, error) {
|
|
|
|
|
user32, err := syscall.LoadLibrary("user32.dll")
|
|
|
|
|
if err != nil {
|
|
|
|
|
break
|
|
|
|
|
return 0, errors.New("Can't Load User32 API")
|
|
|
|
|
}
|
|
|
|
|
formats = append(formats, format)
|
|
|
|
|
defer syscall.FreeLibrary(user32)
|
|
|
|
|
gucf, err := syscall.GetProcAddress(syscall.Handle(user32), "GetUpdatedClipboardFormats")
|
|
|
|
|
if err != nil {
|
|
|
|
|
return 0, errors.New("Can't Load GetUpdatedClipboardFormats API")
|
|
|
|
|
}
|
|
|
|
|
return formats, nil
|
|
|
|
|
r, _, errno := syscall.Syscall(gucf, 3, uintptr(lpuiFormats), uintptr(cFormats), uintptr(pcFormats))
|
|
|
|
|
if r == 0 {
|
|
|
|
|
return 0, error(errno)
|
|
|
|
|
}
|
|
|
|
|
return int(r), nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func GetUpdatedClipboardFormatsAll() ([]DWORD, error) {
|
|
|
|
|
var res []DWORD
|
|
|
|
|
formats := make([]uint32, 32)
|
|
|
|
|
var count uint32
|
|
|
|
|
_, err := GetUpdatedClipboardFormats(unsafe.Pointer(&formats[0]), len(formats), unsafe.Pointer(&count))
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
for i := 0; i < int(count); i++ {
|
|
|
|
|
res = append(res, DWORD(formats[i]))
|
|
|
|
|
}
|
|
|
|
|
return res, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func IsClipboardFormatAvailable(uFormat DWORD) (bool, error) {
|
|
|
|
|