我推荐这样:
struct
{
......//其他不变的部分
int size;
//buf的长度
}
P:=GlobalAlloc(GMEM_DDESHARE or GMEM_MOVEABLE,
Sizeof(Struct)+length(memo1.text)+1);
YourStruct.Size:=Length(Memo1.Text);
Move(YourStruct,P^,SizeOf(Struct));
Move(Memo1.Text,Pointer(Interger(P)+SizeOf(Struct))^,Length(Memo1.Text);
接受:
Move(P^,YourStruct,SizeOf(Struct);
Move(Pointer(Integer(P)+SizeOf(Struct))^,YourPChar,YourStruct.Size)
//看看Pipi.的还有什么方法。