在使用的时候
错误提示是System.EntryPointNotFoundException was unhandled
Unable to find an entry point named 'cpp_add' in DLL 'TestDLL.dll'.
是不是说不能找到dll中函数的入口阿?
那么在vc6中的函数应该怎样定义,才能在C#调用的时候知道入口
vc6中建立工程的时候是选择mfc appwizard(dll)
还是win32 dynamic-link library刚刚接触这方面,不是太懂

解决方案 »

  1.   

    using System.Runtime.InteropServices;[DllImport("XXX.DLL",EntryPoint="GetApiFunction",SetLastError=true)]
    public static extern int GetApiFunction(
        string strParaA,
        StringBuilder strParaB,
        int intParaC,
        out int intParaD,
        bool blnParaE);C++数据类型和C#的部分对应关系:C++           输入输出    C# 
    ==================================
    char chr[255]   O    StringBuilder
    KCA_DIR         I    int
    LPCSTR          I    string
    int             I    int
    LPSTR           O    StringBuilder
    int*            O    out int
    DWORD           I    int
    DWORD*          O    out int
    BOOL            I    bool
    Rc_DBMgr        I    IntPtr
    long*           O    out long
      

  2.   

    用 .def 文件,
    ; TestWINAPI.def : 声明 DLL 的模块参数。LIBRARY      "TestWINAPI"EXPORTS
    MsgBox @1
    func @2
    Database @3
    Database1 @4
    Draw_Code_128 @5
        ; 此处可以是显式导出
    LIBRARY TestWINAPI
      

  3.   

    谢谢
    那个def文件的是怎么搞得哦?
    又没有具体一点的文档阿?
    没有6.0的msdn
      

  4.   

    在 visual studio 6.0 项目里添加 .def 文件呀。
    里面有提示的。
      

  5.   

    我的是在头文件中定义
    #ifdef  _DLL_
    #define DLL_EXP_IMP __declspec(dllexport)
    #else
    #define DLL_EXP_IMP __declspec(dllimport)
    #endifextern "C" DLL_EXP_IMP int _cdecl Hook(DWORD dwSelfProcessID_P);
    extern "C" DLL_EXP_IMP int _cdecl Unhook();#endif