//IntPtr转自定义结构
struct onlydata
{
IntPtr hwnd;
};
onlydata pd=new onlydata();
IntPtr pd;
pd=Marshal.PtrToStructure(pd,typeof(onlydata));

//自定义结构转IntPtr
Marshal.StructureToPtr(data,pd,true);