zenity icon indicating copy to clipboard operation
zenity copied to clipboard

When I call the SelectFile method, it occasionally reports: Incorrect function

Open dongshaoyang opened this issue 1 year ago • 2 comments

func OpenDir() (string, error) {
	path, err := zenity.SelectFile(zenity.Directory())
	if zenity.ErrCanceled == err {
		log.Info("the cancel button is pressed")
		return "", fmt.Errorf("the cancel button is pressed")
	} else if err != nil {
		log.Error("Exception:", err)
		return "", err //it occasionally reports: Incorrect function
	}
	return path, err
}

The code runs on the Windows platform.

dongshaoyang avatar Sep 06 '24 08:09 dongshaoyang

I don't have a windows machine handy. If you can pinpoint which Windows API is returning ERROR_INVALID_FUNCTION it would be extremely helpful. If this is something easily reproducible, that would mean adding logs to every return err in this file and seeing which one is being tripped.

ncruces avatar Sep 06 '24 11:09 ncruces

I found out which method caused the error. The issue occurred in the CoInitializeEx method within the ole32.go file.

func CoInitializeEx(reserved uintptr, coInit uint32) error {
	return windows.CoInitializeEx(reserved, coInit)
}

dongshaoyang avatar Sep 23 '24 02:09 dongshaoyang

The bug has been fixed in the new version.

dongshaoyang avatar Oct 17 '25 09:10 dongshaoyang