Guest User

Untitled

a guest
Jun 21st, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. long func(struct name * myname)
  2. {
  3. strcpy(myname->firstname,"rakesh");
  4. strcpy(myname->lastname,"agarwal");
  5. return S_OK;
  6. }
  7.  
  8. struct name
  9. {
  10. char firstname[100];
  11. char lastname[100];
  12. }
  13.  
  14. [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
  15. unsafe public struct name
  16. {
  17. [MarshalAs(UnmanagedType.ByValTStr, SizeConst=100)]
  18. public string firstname;
  19. [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 100)]
  20. public string lastname;
  21. } ;
  22.  
  23.  
  24. [DllImport("C++Dll.dll")]
  25. public unsafe static extern long func(name[] myname);
  26.  
  27. name[] myname = new name[1];
  28. func(myname);
  29.  
  30. name myname = new name();
  31. func(ref myname);
  32.  
  33. [DllImport("C++Dll.dll")]
  34. public unsafe static extern long func(ref name myname);
Add Comment
Please, Sign In to add comment