[DllImport("gdi32.dll")]
static extern uint SetPixel(IntPtr hdc, int X, int Y, uint crColor);
就可以了[DllImport("gdi32.dll", CallingConvention = CallingConvention.Cdecl)]
这个不对,所有的API都是StdCall的。

解决方案 »

  1.   

    这是标准的win32api,对于这样的api里可以去下一个工具查询 api explorer当然如果不愿意下工具,则可以去pinvoke.net直接搜索
    比如你的这个api搜索出来的结果:http://www.pinvoke.net/default.aspx/gdi32/SetPixel.html
      

  2.   

    哈哈,我就是从pinvoke粘贴来的。事实上,只要用几个关键字,就可以在google中找到,比如"SetPixel extern dllimport"
      

  3.   

    [DllImport("Dll.dll")]改为[DllImport("Dll.dll", CallingConvention=CallingConvention.Cdecl)]
    DllImport的CallingConvention的属性,默认值是CallingCovention.Stdcall,  此处更改成Cdecl(c/c++默认调用方式)就可以了。以上是百度知道上找到的,试了下,果然好用!!!