DLL Import use SYSTEMTIME

c#, dllimport, visual-c++

Solution

That should work:

[StructLayout(LayoutKind.Sequential)]
private struct SYSTEMTIME {
    Int16 wYear;
    Int16 wMonth;
    Int16 wDayOfWeek;
    Int16 wDay;
    Int16 wHour;
    Int16 wMinute;
    Int16 wSecond;
    Int16 wMilliseconds;
}

See also the ready to use solution from pinvoke like Christian.K pointed to.

Problem

I have a dll developed using C++. Now I wish to use these functions in my C# application. I know how to use the dll in my application, but my problem is that the dll expects a parameter which is of type SYSTEMTIME. ``` [DllImport("MyControl.dll")] public static extern Int32 MyCONTROL_NewControl(SYSTEMTIME stime); ``` But I am not able to use the `SYSTEMTIME` in my C# code. Please suggest a workaround on how to use `SYSTEMTIME`.

Original source