go-toast

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

toastnotificationmanager.go (1352B)


      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 (
     16 	GUIDiToastNotificationManagerStatics5      string = "d6f5f569-d40d-407c-8989-88cab42cfd14"
     17 	SignatureiToastNotificationManagerStatics5 string = "{d6f5f569-d40d-407c-8989-88cab42cfd14}"
     18 )
     19 
     20 type iToastNotificationManagerStatics5 struct {
     21 	ole.IInspectable
     22 }
     23 
     24 type iToastNotificationManagerStatics5Vtbl struct {
     25 	ole.IInspectableVtbl
     26 
     27 	GetDefault uintptr
     28 }
     29 
     30 func (v *iToastNotificationManagerStatics5) VTable() *iToastNotificationManagerStatics5Vtbl {
     31 	return (*iToastNotificationManagerStatics5Vtbl)(unsafe.Pointer(v.RawVTable))
     32 }
     33 
     34 func GetDefault() (*ToastNotificationManagerForUser, error) {
     35 	inspectable, err := ole.RoGetActivationFactory("Windows.UI.Notifications.ToastNotificationManager", ole.NewGUID(GUIDiToastNotificationManagerStatics5))
     36 	if err != nil {
     37 		return nil, err
     38 	}
     39 	v := (*iToastNotificationManagerStatics5)(unsafe.Pointer(inspectable))
     40 
     41 	var out *ToastNotificationManagerForUser
     42 	hr, _, _ := syscall.SyscallN(
     43 		v.VTable().GetDefault,
     44 		0,                             // this is a static func, so there's no this
     45 		uintptr(unsafe.Pointer(&out)), // out ToastNotificationManagerForUser
     46 	)
     47 
     48 	if hr != 0 {
     49 		return nil, ole.NewError(hr)
     50 	}
     51 
     52 	return out, nil
     53 }