AllenDang / w32

A wrapper of windows apis for the Go Programming Language.
Other
761 stars 245 forks source link

I've gotten an error "0x3b02 User stopped resource enumeration." while I used the ExtractIcon #79

Open Huaxink opened 6 years ago

Huaxink commented 6 years ago

https://github.com/AllenDang/w32/blob/9a4ee0f7d224efbff75947fa7060daadccc4741c/shell32.go#L146

I just want to get other exe-file icon bytes, but I've gotten the error "0x3b02 User stopped resource enumeration." while I used the ExtractIcon. I have not found out any effective answer by google.

Well, I used the api in my local application built by electron. 4 5

Any idea about this? Thank you!

gonutz commented 4 years ago

Working with the syscall package I have found that it is safer to only use the first of the three return values of Call. In your example you check the err in

ret, _, err := procExtractIcon.Call(

but just ignore that and interpret the ret value according the the MSDN docs. This is the result that the function gives you and it usually contains everything you need to know. I have found in the past that the err might be set but really the function did not fail. I think this is some global error code that might be set by some other function as well and is not reset or something along those lines.

Your link to the code does not actually use the err value anymore which supports my point. It seems to not work for others either.

If you want to use my actively supported fork of this repo, here it is:

https://github.com/gonutz/w32

It does not contain ExtractIcon currently but if you still want that, just create an issue and I will be happy to add it.