Ok, what happens on windows if resource length is 0? If it still works and text is simply empty
Yes, this is the case.
you can detect a failure another way - by testing returned resource pointer (I'd expect NULL if resource id was not found), and in that case use last error.
No, if the resource is not found, lpBuffer remains unchanged on Windows and isn't set to NULL.
I could of course set it to NULL beforehand instead of setting SetLastError. But the current solution uses less code than that. (Except of course I should use "SetLastError(ERROR_SUCCESS)" instead of S_OK, as you noted.) Which one do you prefer?