同上

解决方案 »

  1.   

    [DllImport("名字.dll")]
    public static extern Int32 函数名(参数列表);
    在类中声明上边的东西。
    注意C++和c#的数据类型就行了。
      

  2.   

    [DllImport("名字.dll")]里面给具体路径也行。
      

  3.   

    当然可以调用
    using System;
    using System.Runtime.InteropServices;
    class MainClass 
    {
        [DllImport("User32.dll")]
        public static extern int MessageBox(int h, string m, string c, int type);    static int Main() 
        {
            string myString; 
            Console.Write("Enter your message: ");
            myString = Console.ReadLine();
            return MessageBox(0, myString, "My Message Box", 0);
        }
    }
      

  4.   

    for example:比如:
    你自己创建的DLL:
    // cmdll.c
    // compile with: /LD /MD
    int __declspec(dllexport) SampleMethod(int i)
    {
        return i*10;
    }
    C#中调用:// cm.cs
    using System;
    using System.Runtime.InteropServices;
    public class MainClass 
    {
        [DllImport("Cmdll.dll")]
        public static extern int SampleMethod(int x);
        static void Main() 
        {
            Console.WriteLine("SampleMethod() returns {0}.", 
                    SampleMethod(5));
        }
    }具体可参见MSDN:ms-help://MS.MSDNQTR.v80.chs/MS.MSDN.v80/MS.VisualStudio.v80.chs/dv_csref/html/9c3f02c4-51b8-4d80-9cb2-f2b6e1ae15c7.htm上面就是这里的例子..
      

  5.   

    我以前做了个系统钩子的DLL(好用),这么加上去没有反应。
    没有报错,也没有功能实现。怎么回事?
      

  6.   

    另外我调用的函数是 DllExport void WINAPI Installhook()中的WINAPI怎么在C#表示?
      

  7.   

    WINAPI?这是个入口点函数,要用函数指针,看来你得用delegate了