On 09/15/2014 04:36 PM, notna wrote:

>          WCHAR lpwszUsername[254];
>          debug writefln("lpwszUsername.sizeof is %s, WCHAR.sizeof is
> %s", lpwszUsername.sizeof, WCHAR.sizeof);
>          // DWORD dUsername2 = lpwszUsername.sizeof / WCHAR.sizeof;
>          DWORD dUsername2 = 254;
>          GetUserNameW(lpwszUsername.ptr, &dUsername2);

You must make use of the returned value to slice your wstring. Something like this (not compiled):

    auto actualLength = GetUserNameW(lpwszUsername.ptr, &dUsername2);
    auto userName = lpwszUsername[0..actualLength];

Otherwise, D knows that lpwszUsername is a 254-char string and will try to print all of it.

Ali

Reply via email to