[DllImport("gdi32.dll")]
static extern uint SetPixel(IntPtr hdc, int X, int Y, uint crColor);
就可以了[DllImport("gdi32.dll", CallingConvention = CallingConvention.Cdecl)]
这个不对,所有的API都是StdCall的。
static extern uint SetPixel(IntPtr hdc, int X, int Y, uint crColor);
就可以了[DllImport("gdi32.dll", CallingConvention = CallingConvention.Cdecl)]
这个不对,所有的API都是StdCall的。
比如你的这个api搜索出来的结果:http://www.pinvoke.net/default.aspx/gdi32/SetPixel.html
DllImport的CallingConvention的属性,默认值是CallingCovention.Stdcall, 此处更改成Cdecl(c/c++默认调用方式)就可以了。以上是百度知道上找到的,试了下,果然好用!!!