stream.Seek(0, SeekOrigin.Begin);
int dataSize = Convert.ToInt32(stream.Length);
byte[] byteArray = new byte[dataSize];
int count = stream.Read(byteArray, 0, 20);
while(count < stream.Length)
{
byteArray[count++] = Convert.ToByte(stream.ReadByte());
}
IntPtr ptrData = Marshal.AllocCoTaskMem(dataSize);
Marshal.Copy(byteArray, 0, ptrData, dataSize);
CopyDataStruct cds = new CopyDataStruct
cbData = dataSize,
dwData = (IntPtr)1,
lpData = ptrData
};
SendMessage(hWnd, WM_COPYDATA, 0, cds);
Thanks