On Wednesday, 17 June 2015 at 20:40:02 UTC, Dan wrote:
I'm new to Dlang and I have no Idea whats wrong with this code!

wchar[260] buffer;
HWND hWindow = GetForegroundWindow();
GetWindowTextW(hWindow, buffer, sizeof(title)); <-- Problem here

The compiler is complaining it can't find an identifier named GetWindowTextW, so you'll have to declare it yourself.

Try this:

  extern(Windows)
  int GetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount);

And call it like so:

  wchar[MAX_PATH] buffer;
int length = GetWindowTextW(GetForegroundWindow(), buffer.ptr, buffer.length);

Reply via email to