Hi, I have such simple structure in unmanaged C++: struct Cam { char ip[16]; char login[16]; char pass[16]; char name[16]; }; and C# marshalled structure: [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)] public struct Cam { [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 16)] public string ip; [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 16)] public string login; [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 16)] public string pass; [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 16)] public string name; } When I pass C# struct to C++ lib by function [DllImport("NVRLib.dll", CallingConvention = CallingConvention.Cdecl)] public static extern void AddCameraStruct(Cam cam); ... Cam cam = new Cam(); cam.ip = "192.168.0.232"; cam.login = "admin"; cam.pass = "admin"; …

Member Avatar
Member Avatar
+0 forum 1

hi, well i have posted this on two other forums without success, hoprfuly you guys can help me ! the scenario - i have a native c++ dll that creates and initializes a string, which is a char array. [CODE] char pRet[1024]; memset(pRet, 0, 1024); strcpy(pRet, "change me!"); [/CODE] the c++ dll then fires a callback function, and the callback function must change the value of the string. however, the callback function is in a VB.NET app. the callback function is defined in the c++ dll as : [CODE] typedef VOID (WINAPI *CALLBACK_ROUTINE)(char* pRet); [/CODE] so the delegate type that …

Member Avatar
+0 forum 0

The End.