(nint InHandle, char* InBuffer, int InSize)
| 17 | } |
| 18 | |
| 19 | [UnmanagedCallersOnly] |
| 20 | public static int GetString(nint InHandle, char* InBuffer, int InSize) |
| 21 | { |
| 22 | if (InBuffer != null && InSize > 0) |
| 23 | { |
| 24 | if (HandleData.GetObject(InHandle) is string String) |
| 25 | { |
| 26 | var Length = String.Length; |
| 27 | |
| 28 | if (Length < InSize) |
| 29 | { |
| 30 | fixed (char* Ptr = String) |
| 31 | { |
| 32 | Buffer.MemoryCopy(Ptr, InBuffer, (InSize - 1) * sizeof(char), Length * sizeof(char)); |
| 33 | } |
| 34 | |
| 35 | InBuffer[Length] = '\0'; |
| 36 | |
| 37 | return Length; |
| 38 | } |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | return -1; |
| 43 | } |
| 44 | } |
| 45 | } |