I am working on simple telephony application where I am changing the class of service of panasonic pbx extension. For that I am using \"Tapi32.dll\" which has methods in c++
[DllImport("Tapi32.dll", SetLastError=true)]
unsafe private static extern int lineDevSpecific(int* hLine, IntPtr lpParams);
unsafe static void Main(string[] args) {
int vline=int.Parse("Ext101");
int* hline=&vline;
var sizeUserRec=Marshal.SizeOf(typeof(UserRec));
var userRec=Marshal.AllocHGlobal(sizeUserRec);
lineDevSpecific(hline, userRec);
var x=(UserRec)Marshal.PtrToStructure(userRec, typeof(UserRec));
Marshal.FreeHGlobal(userRec);
}
Take a look of this answer of question
You can find some more to make marshalling easier and more reusable.