C#中的API声明格式比较特别,建议你找个像API Viewer的东东。
可以在http://www.c-sharpcorner.com/找到。
如果你能给出EMAIL地址的话,我可以给你发一个过去。

解决方案 »

  1.   

    give me 
    [email protected]
      

  2.   

    1.在C#中使用API函数。①若API函数中有结构类型的参数时,要使用[StructLayout(布局选项)],目的是要格式化这个类型,以保持参数原有的布局和对齐。其中布局选项有:
    LayoutKind.Automatic——为了提高效率允许运行态对类型成员重新排序。 注意:永远不要使用这个选项来调用不受管辖的动态链接库函数。 
    LayoutKind.Explicit——对每个域按照FieldOffset属性对类型成员排序 
    LayoutKind.Sequential——对出现在受管辖类型定义地方的不受管辖内存中的类型成员进行排序。
    StructLayout后是对结构的重新定义,但只是对原结构成员的类型的重新定义(要符合标准)。
    对每个结构的重新定义都需StructLayout。 
    当API函数返回句柄时用IntPtr。如HDC就要用IntPtr。
    ②先使用using System.InteropServices。先声明API函数后使用。
    格式:[DllImport(库名,EntryPoint=函数名,CharSet=CharSet.Unicode,ExactSpelling=ture)]
          public static extern 类型 函数名(参数);
    其中CharSet表示采用的是Unicode或ANSI版本,ExactSpelling=false表示让编译器决定使用哪个版本。在public语句中可对函数改名。如:[DllImport(:”User32.dll”)];
    以类作参数和以结构作参数是一样的。
    ③回调函数的传递:⑴创建delegate类型的回调函数,如:public delegate bool CallBack();
    ⑵创建回调函数的实例,将实例作参数用在API函数中。如:CallBack e=new CallBack()
    ④指针类型参数传递:将指针类型转化为数组类型。
    一个例子:using System.Runtime.InteropServices;  [StructLayout(LayoutKind.Sequential)]        public struct Point { public int x; public int y; }
    [DllImport("User32.dll")]       public static extern Bool PtInRect(ref Rect r, Point p);
      

  3.   

    thank you 
    [email protected]
      

  4.   

    Calling an API in C# is similar to calling an API in VB. You should know the DLL name of the API and import it by using sysimport. This sample shows how to call MessageBox API.
      
    using System; class callAPICls {            [sysimport(dll="user32.dll")]             public static extern int MessageBoxA(int h, string m, string c, int type);            public static int Main()             {                     return MessageBoxA(0, "Hello World!", "Caption", 0);             }  } 
      

  5.   

    谢了,,兄弟们,特别是icyer兄