Guest User

Untitled

a guest
Jan 21st, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. [DllImport("essentials.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
  2. public static extern System.IntPtr GetFiles(string filedir, string path);
  3.  
  4. [STAThread]
  5. static void Main()
  6. {
  7. string filedir = @"C:UsersRubenDocumentsSchool*";
  8. string path = @"C:UsersRubenDocumentsSchool";
  9. System.IntPtr pointer = GetFiles(filedir, path);
  10. string files = Marshal.PtrToStringAnsi(pointer); // nothing
  11. }
  12.  
  13. extern "C"
  14. {
  15. __declspec(dllexport) char* GetFiles(char* filedir, char* path)
  16. {
  17. string filedir2 = filedir;
  18. string path2 = path;
  19. string files = GetFiles2(filedir2, path2);
  20. char* Rfiles = new char[files.length() + 1];
  21. strcpy_s(Rfiles, files.length() + 1, files.c_str());
  22. return Rfiles;
  23. }
  24. }
  25.  
  26. [DllImport("essentials.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
  27. public static extern System.IntPtr GetFiles
  28. ([MarshalAs(UnmanagedType.AnsiBStr)]string filedir,
  29. [MarshalAs(UnmanagedType.AnsiBStr)]string path);
Add Comment
Please, Sign In to add comment