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

Windows 32-bit system will get stuck when executing. #45

Open
c17abab opened this issue Apr 12, 2023 · 3 comments
Open

Windows 32-bit system will get stuck when executing. #45

c17abab opened this issue Apr 12, 2023 · 3 comments
Labels
bug Something isn't working platform-specific

Comments

@c17abab
Copy link

c17abab commented Apr 12, 2023

The compilation parameters are as follows:
$env:GOARCH="amd64";
$env:GOOS="windows";
$env:GOARCH="386"; # 32
#$env:GOARCH="amd64"; # 64

and the program will be stucked at line 324 in the file clipborad_windows.go:

println("test in read 2")
// try again until open clipboard successed
   // will stuck here
for {
	r, _, _ = openClipboard.Call()
	if r == 0 {
		continue
	}
	break
}
    //  the following code will not be executed.
println("test in read 3")
@changkun
Copy link
Member

Good point. Is there any specific use case for 32-bit windows? I am 99% sure that this package didn't consider 32-bit windows.

@c17abab
Copy link
Author

c17abab commented Apr 12, 2023

Good point. Is there any specific use case for 32-bit windows? I am 99% sure that this package didn't consider 32-bit windows.

Found the cause of the problem, the user32.dll function openClipboard need a parameter(A handle to the window to be associated with the open clipboard. If this parameter is NULL, the open clipboard is associated with the current task). So maybe you need to get the window handle first, or set the parameter to 0:
https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-openclipboard

eg:

	// Here you need to get the handle of the clipboard window first
	getOpenClipboardWindow := user32.MustFindProc("GetOpenClipboardWindow")
	for {
		r, _, _ = getOpenClipboardWindow.Call()
                // set the parameter to 0 is also ok
		r, _, _ = openClipboard.Call(r)
		if r == 0 {
			continue
		}
		break
	}
	defer closeClipboard.Call()

@changkun
Copy link
Member

Thanks for the investigation. As you already investigated the issue, any PR would be very welcome 👍

@changkun changkun added bug Something isn't working platform-specific labels Apr 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working platform-specific
Projects
None yet
Development

No branches or pull requests

2 participants