Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
dongshaoyang opened this issue Sep 6, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@dongshaoyang
Copy link

dongshaoyang commented Sep 6, 2024

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.

@ncruces
Copy link
Owner

ncruces commented Sep 6, 2024

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 ncruces added the bug Something isn't working label Sep 6, 2024
@dongshaoyang
Copy link
Author

dongshaoyang commented Sep 23, 2024

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)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants