(WinAPI) FindWindowW always fails
Dennis
dkorpel at gmail.com
Thu Oct 8 19:49:04 UTC 2020
On Thursday, 8 October 2020 at 19:39:05 UTC, Deen O'Connor wrote:
> wstring wndName = "x32dbg";
> HWND hWnd = FindWindowW(null, cast(wchar*)&wndName);
Dont take the address of the `wstring`, use `wndName.ptr` instead.
wstring is internally a fat pointer that looks like this:
struct wstring {
size_t length;
immutable(wchar)* ptr;
}
When taking the address `&wndName`, you get a pointer to this
struct on the stack, not the actual string literal.
More information about the Digitalmars-d
mailing list