go-toast

Send toast notifications in Windows
Log | Files | Refs | README | LICENSE

toastnotifier.go (1494B)


      1 // Code generated by winrt-go-gen. DO NOT EDIT.
      2 
      3 //go:build windows
      4 
      5 //nolint:all
      6 package notifications
      7 
      8 import (
      9 	"syscall"
     10 	"unsafe"
     11 
     12 	"github.com/go-ole/go-ole"
     13 )
     14 
     15 const SignatureToastNotifier string = "rc(Windows.UI.Notifications.ToastNotifier;{75927b93-03f3-41ec-91d3-6e5bac1b38e7})"
     16 
     17 type ToastNotifier struct {
     18 	ole.IUnknown
     19 }
     20 
     21 func (impl *ToastNotifier) Show(notification *ToastNotification) error {
     22 	itf := impl.MustQueryInterface(ole.NewGUID(GUIDiToastNotifier))
     23 	defer itf.Release()
     24 	v := (*iToastNotifier)(unsafe.Pointer(itf))
     25 	return v.Show(notification)
     26 }
     27 
     28 const (
     29 	GUIDiToastNotifier      string = "75927b93-03f3-41ec-91d3-6e5bac1b38e7"
     30 	SignatureiToastNotifier string = "{75927b93-03f3-41ec-91d3-6e5bac1b38e7}"
     31 )
     32 
     33 type iToastNotifier struct {
     34 	ole.IInspectable
     35 }
     36 
     37 type iToastNotifierVtbl struct {
     38 	ole.IInspectableVtbl
     39 
     40 	Show                           uintptr
     41 	Hide                           uintptr
     42 	GetSetting                     uintptr
     43 	AddToSchedule                  uintptr
     44 	RemoveFromSchedule             uintptr
     45 	GetScheduledToastNotifications uintptr
     46 }
     47 
     48 func (v *iToastNotifier) VTable() *iToastNotifierVtbl {
     49 	return (*iToastNotifierVtbl)(unsafe.Pointer(v.RawVTable))
     50 }
     51 
     52 func (v *iToastNotifier) Show(notification *ToastNotification) error {
     53 	hr, _, _ := syscall.SyscallN(
     54 		v.VTable().Show,
     55 		uintptr(unsafe.Pointer(v)),            // this
     56 		uintptr(unsafe.Pointer(notification)), // in ToastNotification
     57 	)
     58 
     59 	if hr != 0 {
     60 		return ole.NewError(hr)
     61 	}
     62 
     63 	return nil
     64 }