C#怎么调用MFC做的DLL动态链接库文件,怎么使用DLL里面的函数?
请前辈们指教,或者有没有实例代码提供我参考,谢谢!!!

解决方案 »

  1.   

    1、 DLL文件必须位于程序当前目录或系统定义的查询路径中
    2、 “using System.Runtime.InteropServices;”
    3、[DllImport("user32.dll", EntryPoint="MessageBoxA")]
    static extern int MsgBox(int hWnd, string msg, string caption, int type);
      

  2.   

    基本类型对应
    C++            C#
    =====================================
    WORD            ushort
    DWORD            uint
    UCHAR            int/byte   大部分情况都可以使用int代替,而如果需要严格对齐的话则应该用bytebyte 
    UCHAR*            string/IntPtr
    unsigned char*         [MarshalAs(UnmanagedType.LPArray)]byte[]/?(Intptr)
    char*            string
    LPCTSTR            string
    LPTSTR            [MarshalAs(UnmanagedType.LPTStr)] string
    long            int
    ulong               uint
    Handle            IntPtr
    HWND            IntPtr
    void*            IntPtr
    int            int
    int*            ref int
    *int            IntPtr
    unsigned int        uint
    COLORREF                uint
      

  3.   

    http://blog.csdn.net/jianuMan/archive/2010/06/13/5669934.aspx
      

  4.   

    关于动态调用Dll的方法
    http://blog.csdn.net/null1/archive/2009/03/03/3953155.aspx
      

  5.   

    DllImport
    http://topic.csdn.net/u/20090225/15/a6bc50ad-9721-4749-b189-dc4a4bc045a1.html
      

  6.   


    PInvoke.com这个网站可以帮助你