It's been a while since then, but the problem with the structure has been solved.
The reason seems to be that the structure name defined in core.sys.windows.windef was not tagRECT.
I was able to get it to compile by adding a custom definition as follows
extern (C)
struct tagRECT
{
LONG left;
LONG top;
LONG right;
LONG bottom;
}
alias RECT = tagRECT;
The type name did not work.
The reason seems to be that WCHAR should be mangled with wcha_t, but it is mangled with chat16_t.
Since the mangle is wchat_t, I thought maybe I should use wchar_t in core.stdc.stdef, so I changed LPCWSTR to const (wchar_t)*, but that didn't work either.
I still haven't solved this problem.
I also took a look at Data Type Compatibility in Interfacing to C++, and I think it's wrong about wchar_t.
https://dlang.org/spec/cpp_interface.html#data-type-compatibility