D
dast
I would need a function to copy unsigned short values from a IntPtr to
a ushort[]-array, but the Marshal.Copy-function only support the
short[]-array!
At the moment I do it the following way:
...
IntPtr pResult;
int len;
// this function is located in a DLL
CanIpuExecCmd(mid, hid, did, data, data.Length, out pResult, out
len);
short[] tmp = new short[len];
Marshal.Copy(pResult, tmp, 0, len);
Marshal.FreeHGlobal(pResult);
ushort[] result = new ushort[tmp.Length];
tmp.CopyTo(result, 0);
return result;
Is there no nicer way?
Regards,
Daniel.
a ushort[]-array, but the Marshal.Copy-function only support the
short[]-array!
At the moment I do it the following way:
...
IntPtr pResult;
int len;
// this function is located in a DLL
CanIpuExecCmd(mid, hid, did, data, data.Length, out pResult, out
len);
short[] tmp = new short[len];
Marshal.Copy(pResult, tmp, 0, len);
Marshal.FreeHGlobal(pResult);
ushort[] result = new ushort[tmp.Length];
tmp.CopyTo(result, 0);
return result;
Is there no nicer way?
Regards,
Daniel.