Closed dbremner closed 8 years ago
I'm guessing the "should pass its second argument as a ref" is only a perf optimization. And in that case, that's why the primary p/invoke signature we write for many of these methods takes a pointer:
private unsafe void SomeFunc() {
PAINTSTRUCT ps; // initialized elsewhere.
User32.EndPaint(hwnd, &ps);
}
If ref
really is so much more convenient than the pointer approach (I'd like to learn how that is) then the caller can define a helper method that wraps the pointer usage.
User32.EndPaint(System.IntPtr hWnd, PInvoke.User32.PAINTSTRUCT lpPaint) function should pass its second argument as a ref. I noticed this while updating a project to 0.3.152. The associated pull request works around the problem by changing the Friendly attribute from FriendlyFlag.In to FriendlyFlag.Bidirectional.