1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

convert memcpy() C++ to C#

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

  1. Yo123456

    Yo123456 New Member

    Apr 21, 2010
    Likes Received:
    Trophy Points:
    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