我有一个本地方法,它需要一个指针来写出一个双字(uint)。如何从带有编组的指针读取uint?
现在我需要从(Int)指针得到实际的uint值,但Marshal类只有读取(带符号)整数的方便方法。
如何从指针中获取uint值?
我搜索了问题(和谷歌),但无法真正找到我需要的。
样品(不工作)代码:
IntPtr pdwSetting = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(uint)));
try
{
// I'm trying to read the screen contrast here
NativeMethods.JidaVgaGetContrast(_handleJida, pdwSetting);
// this is not what I want, but close
var contrast = Marshal.ReadInt32(pdwSetting);
}
finally
{
Marshal.FreeHGlobal(pdwSetting);
}
从本机函数的返回值是255是全对比度0和255之间的双字。
您能否提供您的示例代码供我们参考。 – 2012-08-06 13:20:08