On Tuesday, 9 July 2019 at 11:11:53 UTC, Dejan Lekic wrote:
Now that I browsed the std.utf more, I realised what fits your need best is the https://dlang.org/phobos/std_utf.html#toUTF16z

So far, this is what I have:


Filename: myVersion.d

import core.sys.windows.windows : SendMessageTimeoutW;
import core.sys.windows.windows : GetLastError;
import core.sys.windows.windows : ERROR_SUCCESS;
import core.sys.windows.windows : SMTO_ABORTIFHUNG;
import core.sys.windows.windows : LPARAM;
import core.sys.windows.windows : HWND_BROADCAST;
import core.sys.windows.windows : WM_SETTINGCHANGE;

import std.utf;

void main(){
        broadcastSettingChange();

}

void broadcastSettingChange (string envi="Environment", uint timeout=1)
{

    auto result = SendMessageTimeoutW(
        HWND_BROADCAST,
        WM_SETTINGCHANGE,
        0,
        envi.toUTF16z,
        SMTO_ABORTIFHUNG,
        timeout,
        null
    );

    if(result == 0)
    {
        auto errCode = GetLastError();
    }
 }



The dmd output:
C:\Users\User\Desktop>rdmd ref.d
ref.d(19): Error: function `core.sys.windows.winuser.SendMessageTimeoutW(void*, uint, uint, int, uint, uint, uint*)` is not callable using argument types `(void*, int, int, const(wchar)*, int, uint, typeof(null))` ref.d(19): cannot pass argument `toUTF16z(cast(const(char)[])envi)` of type `const(wchar)*` to parameter `int` Failed: ["C:\\D\\dmd2\\windows\\bin\\dmd.exe", "-v", "-o-", "ref.d", "-I."]



Reply via email to