diff --git a/file_windows.go b/file_windows.go index d80a950..fa0e526 100644 --- a/file_windows.go +++ b/file_windows.go @@ -3,7 +3,6 @@ package zenity import ( "path/filepath" "reflect" - "runtime" "syscall" "unicode/utf16" "unsafe" @@ -315,9 +314,8 @@ func browseForFolder(opts options) (string, []string, error) { args.Title = syscall.StringToUTF16Ptr(*opts.title) } if opts.filename != "" { - args.LParam = strptr(opts.filename) + args.LParam = syscall.StringToUTF16Ptr(opts.filename) args.CallbackFunc = syscall.NewCallback(browseForFolderCallback) - defer runtime.KeepAlive(opts.filename) } if opts.ctx != nil { @@ -420,7 +418,7 @@ type _BROWSEINFO struct { Title *uint16 Flags uint32 CallbackFunc uintptr - LParam uintptr + LParam *uint16 Image int32 } diff --git a/msg_windows.go b/msg_windows.go index 6df6ad5..13bce39 100644 --- a/msg_windows.go +++ b/msg_windows.go @@ -2,7 +2,6 @@ package zenity import ( "context" - "runtime" "syscall" "unsafe" ) @@ -53,13 +52,12 @@ func message(kind messageKind, text string, opts options) error { defer unhook() } - var title uintptr + var title *uint16 if opts.title != nil { - title = strptr(*opts.title) - defer runtime.KeepAlive(*opts.title) + title = syscall.StringToUTF16Ptr(*opts.title) } - s, _, err := messageBox.Call(0, strptr(text), title, flags) + s, _, err := messageBox.Call(0, strptr(text), uintptr(unsafe.Pointer(title)), flags) if opts.ctx != nil && opts.ctx.Err() != nil { return opts.ctx.Err() diff --git a/util_windows.go b/util_windows.go index 95b78f3..3625280 100644 --- a/util_windows.go +++ b/util_windows.go @@ -525,6 +525,7 @@ func uuid(s string) uintptr { type _COMObject struct{} +//go:uintptrescapes func (o *_COMObject) Call(trap uintptr, a ...uintptr) (r1, r2 uintptr, lastErr error) { switch nargs := uintptr(len(a)); nargs { case 0: