public DirEntry GetDirEntry(uint dirIndex) { try { DirEntry d = new DirEntry(); IntPtr buffer = Marshal.AllocHGlobal(Marshal.SizeOf(d.GetType())); // ... send buffer to dll cppToCsharpAdapter.getDirEntry(this.myDiskPointer, buffer, dirIndex); Marshal.PtrToStructure(buffer, d); // free allocate Marshal.FreeHGlobal(buffer); return(d); } catch (SEHException) { IntPtr cString = cppToCsharpAdapter.getLastDiskErrorMessage(this.myDiskPointer); throw new Exception(Marshal.PtrToStringAnsi(cString)); } }
public List <DirEntry> GetDirRoot() { try { List <DirEntry> list = new List <DirEntry>(); for (uint i = 0; i < 28; i++) { DirEntry idir = this.GetDirEntry(i); if (idir.EntryStatus == '1') { list.Add(this.GetDirEntry(i)); } } return(list); } catch (SEHException) { IntPtr cString = cppToCsharpAdapter.getLastDiskErrorMessage(this.myDiskPointer); throw new Exception(Marshal.PtrToStringAnsi(cString)); } }
public DirEntry GetFileDescription() { try { DirEntry d = new DirEntry(); IntPtr buffer = Marshal.AllocHGlobal(Marshal.SizeOf(d.GetType())); // ... send buffer to dll cppToCsharpAdapter.getFileDesctription(this.myFCBpointer, buffer); Marshal.PtrToStructure(buffer, d); // free allocate Marshal.FreeHGlobal(buffer); return(d); } catch (SEHException) { IntPtr cString = cppToCsharpAdapter.getLastFcbErrorMessage(this.myFCBpointer); string message = Marshal.PtrToStringAnsi(cString); throw new Exception(message); } catch { throw; } }