convert memcpy() C++ to C#

Discussion in 'C#' started by Yo123456, Apr 21, 2010.

  1. Yo123456

    Yo123456 New Member

    Joined:
    Apr 21, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    C++ code(working)
    {
    void CALLBACK MessageCallback(LONG lCommand, NET_DVR_ALARMER *pAlarmer, char *pAlarmInfo, DWORD dwBufLen, void* pUser)

    NET_DVR_ALARMINFO m_struAlarmInfo;
    memcpy(&m_struAlarmInfo, pAlarmInfo, sizeof(NET_DVR_ALARMINFO));
    }

    C# code (Not working)
    {
    public void MessageCallback(Int32 lCommand, ref CHCNetSDK.NET_DVR_ALARMER pAlarmer, [MarshalAs(UnmanagedType.LPStr)] string pAlarmInfo, UInt32 dwBufLen, IntPtr pUser)

    CHCNetSDK.NET_DVR_ALARMINFO m_struAlarmInfo;
    Array.Copy(m_struAlarmInfo, pAlarmInfo.ToCharArray(), (int)dwBufLen);
    }
    Some how for the C# code cannot work when i debug the code it will give me error


    Error 1:The best overloaded method match for 'System.Array.Copy(System.Array, System.Array, int)' has some invalid arguments

    Error 2 :Argument '1': cannot convert from 'AlarmMgtApps.CHCNetSDK.NET_DVR_ALARMINFO' to 'System.Array'

    anyone keen to help?
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice