CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2006
    Posts
    11

    [RESOLVED] Help on Struct

    Hi I'm trying to convert Embedded C++ application to C#.
    I'm stuck with Struct conversion problem. Here is the detail of my problem.
    I hope anyon can help me please. Thanks in advanced.

    C++
    typedef struct __SMSPARAMS {
    DWORD Index;
    TCHAR SMS_Status[1024];
    TCHAR CallerID[1024];
    DATETIMEPARAMS DateTime;
    DWORD msglength;
    TCHAR message[1024];
    } SMSPARAMS, *PSMSDPARAMS;


    typedef struct __LSMSPARAMS {
    SMSPARAMS *lsmsParams[50];
    } LSMSPARAMS, *PLSMSDPARAMS;


    LSMSPARAMS pLSMSParams;

    function A(int *MsgCount,LSMSPARAMS *pSMSParamsStruct);
    -------------------------------------------------------------------------------------------

    How should I convert this struct into C# ? Especially the "LSMSPARAMS" ?

    I have tried the following but, it's not working.


    C#
    public struct SMSPARAMS
    {
    [MarshalAs(UnmanagedType.U4)]
    int Index;
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 1024)]
    public string SMS_Status;
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 1024)]
    public string CallerID;
    DATETIMEPARAMS DateTime;
    [MarshalAs(UnmanagedType.U4)]
    int msglength;
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 1024)]
    public string message;
    }

    public struct LSMSPARAMS
    {
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 50)]
    public SMSPARAMS[] pSMSPARAM;
    }

    function A(ref int MsgCount,ref LSMSPARAMS pSMSParamsStruct);

    Anyone please help me...

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Help on Struct


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured