On Tuesday, 22 January 2019 at 14:07:48 UTC, Olivier Pisano wrote:
On Tuesday, 22 January 2019 at 13:55:30 UTC, FrankLike wrote:

In D, there is only Unicode. The language doesn't manipulate strings encoded in Windows local code-pages.

For example:

 std::wstring strTest(_T("d://"));
 UINT nRes = ::GetDriveType(strTest.c_str());

It can work in C++.
But:
//////////////////////////here is work ok///////////////////////////////////////
import std.stdio;
import std.string;
import std.conv;
import win32.winbase;

void main()
{
        string  strA_Z ="CD";
        auto type = GetDriveType((to!string(strA_Z[0])~":\\").toStringz);
        writeln(to!string(strA_Z[0])~" is ",type);
}
//////////////////////////here is work error//////////////////////////////////////////

import core.sys.windows.windows;
import std.stdio;
import std.string;
import std.conv;

void main()
{
        string  strA_Z ="CD";
        auto type = GetDriveType((to!string(strA_Z[0])~":\\").toStringz);
        writeln(to!string(strA_Z[0])~" is ",type);
}

////////////////////////////////////////////////////////////////////
 //---------------Error Info--------------------//
slicea2.d(9): Error: function core.sys.windows.winbase.GetDriveTypeW(const(wchar
)*) is not callable using argument types (immutable(char)*)
slicea2.d(9): cannot pass argument toStringz(to(strA_Z[0]) ~ ":\\") of ty
pe immutable(char)* to parameter const(wchar)*


Some error is "core.sys.windows.windows"?

Thank you.


Reply via email to