Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- IntPtr CopyToGlobalMemory(string text)
- {
- var bytes = System.Text.Encoding.Default.GetBytes(text);
- var mem = Marshal.AllocHGlobal(bytes.Length + 1);
- Marshal.Copy(bytes, 0, mem, bytes.Length);
- bytes[0] = 0;
- Marshal.Copy(bytes, 0, (IntPtr)((long)mem + bytes.Length), 1);
- return mem;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement