Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Ansi)]
  2. public struct UserProfileData
  3. {
  4. int userProfileRevision;
  5. [MarshalAs(UnmanagedType.LPStr)]
  6. public String firstName;
  7. [MarshalAs(UnmanagedType.LPStr)]
  8. public String lastName;
  9. [MarshalAs(UnmanagedType.LPStr)]
  10. public String memberids;
  11. [MarshalAs(UnmanagedType.LPStr)]
  12. public String emailAddress;
  13. }
  14.  
  15. typedef struct userProfile
  16. {
  17. int profileRevision;
  18. char *firstName;
  19. char *lastName;
  20. char *memberids;
  21. char *emailAddress;
  22. } userProfile_t;
  23.  
  24. int getUserProfileData(userProfile_t *pUserProfile);
  25.  
  26. [StructLayout(LayoutKind.Sequential)]
  27. public struct UserProfileData
  28. {
  29. int userProfileRevision;
  30. public IntPtr firstName;
  31. public IntPtr lastName;
  32. public IntPtr memberids;
  33. public IntPtr emailAddress;
  34. }
  35.  
  36. [DllImport(@"mydll.dll", CallingConvention=CallingConvention.???)]
  37. private static extern int getUserProfileData(out UserProfileData userProfile);
  38.  
  39. string firstName = Marshal.PtrToStringAnsi(userProfile.firstName);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement