1

I use this code for call WFSStartUp via C# program

[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Ansi)]
public unsafe struct WFSVERSION
{
    public ushort wVersion;
    public ushort wLowVersion;
    public ushort wHighVersion;
    public fixed char szDescription[256 + 1];
    public fixed char szSystemStatus[256 + 1];
}

[DllImport("msxfs.dll", CharSet = CharSet.Ansi, CallingConvention = XFSConstants.CALLINGCONVENTION)]
public static extern int WFSStartUp(int dwVersionsRequired, ref WFSVERSION lpWFSVersion);

WFSVERSION m_Version = new WFSVERSION();

int requestVersion = 0x00010202;

int hResult = WFSStartUp(requestVersion, ref m_Version);

the return value hResult is Ok but m_Version.szDescription not correct (m_Version.szDescription[0] = 'W', m_Version.szDescription[1] = 0, ...)

How to solve this problem?

Roman
  • 11,966
  • 10
  • 38
  • 47
behnia_k
  • 11
  • 4
  • 1
    when i call this function from C code szDescription field fill with "WOSA/XFS API v3.00/v2.00" and szSystemStatus field is empty – behnia_k Feb 18 '17 at 13:36
  • 1
    Solved Change struct WFSVERSION public unsafe struct WFSVERSION { public ushort wVersion; public ushort wLowVersion; public ushort wHighVersion; [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256 + 1)] public string szDescription; [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256 + 1)] public string szSystemStatus; } – behnia_k Apr 04 '17 at 09:57

0 Answers0