疑难问题啊!数据拷贝
[DllImport("kernel32", EntryPoint = "RtlMoveMemory", ExactSpelling = true, CharSet = CharSet.Ansi, SetLastError = true)]
private static extern void CopyMemory(object Destination, object Source, long Length);
private static string aa(byte[] fbytFile)
{
dim dbl as double
CopyMemory(ByVal VarPtr(dbl), ByVal VarPtr(fbytFile(0)) + 90, 8)
}
这是VB6的一段代码.调用了一个API.
哪位帮下我,写成C#要怎么写啊
------解决方案--------------------private static string aa(byte[] fbytFile) --->VB是这样吗?
{
double dbl ;
CopyMemory(object VarPtr(dbl), object (VarPtr(fbytFile(0)) + 90), 8) ;
}
private static void CopyMemory(object Destination, object Source, long Length);
------解决方案--------------------参考如下代码
C# code
[DllImport("kernel32", EntryPoint = "RtlMoveMemory")]
private static extern void CopyMemory(
IntPtr destination, IntPtr source, int length);
private static string aa(byte[] fbytFile)
{
double[] dbl = new double[1];
CopyMemory(Marshal.UnsafeAddrOfPinnedArrayElement(dbl, 0),
Marshal.UnsafeAddrOfPinnedArrayElement(fbytFile, 0),
Marshal.SizeOf(typeof(double)));
return dbl[0].ToString();
}
private void button1_Click(object sender, EventArgs e)
{
double[] d = new double[] { 20071009 };
byte[] b = new byte[8];
Buffer.BlockCopy(d, 0, b, 0, 8);
Text = aa(b);
}