On 14/02/2018 1:52 PM, psychoticRabbit wrote:
On Wednesday, 14 February 2018 at 12:29:13 UTC, rikki cattermole wrote:


See:
https://msdn.microsoft.com/en-us/library/windows/desktop/aa364935(v=vs.85).aspx

any idea on how I'd convert this C# code to D?

==============================
public class Program
{

     [DllImport("kernel32.dll")]
         [return:MarshalAs(UnmanagedType.Bool)] static extern bool
         GetDiskFreeSpaceEx(string lpDirectoryName,
             out ulong lpFreeBytesAvailable,
             out ulong lpTotalNumberOfBytes,
             out ulong lpTotalNumberOfFreeBytes);

     static void Main()
     {
         string dir = "C:\\";

         ulong lpFreeBytesAvailable;
         ulong lpTotalNumberOfBytes;
         ulong lpTotalNumberOfFreeBytes;

        GetDiskFreeSpaceEx(dir, out lpFreeBytesAvailable, out lpTotalNumberOfBytes, out lpTotalNumberOfFreeBytes);

         Console.WriteLine(lpFreeBytesAvailable");
         Console.WriteLine(lpTotalNumberOfBytes");
         Console.WriteLine(lpFreeBytesAvailable");

     }
}

=================================

import core.sys.windows.winbase : GetDiskFreeSpaceEx;

Use wstring's and .ptr them and everything should work.

Reply via email to