小编J_C*_*COL的帖子

通过DllImport调用非托管函数时,堆已损坏

我正在使用从C#应用程序以C / C ++编写的非托管dll。我对使用dll中的以下功能感兴趣:

    static void StorePath(const std::string& path, wchar_t *out_path,
     int *out_path_length){
      wcslcpy(out_path, c_str_w(path), *out_path_length);
      *out_path_length = path.size();
     }

    int WINAPI BrowseForDirectory(
     int allow_portable, int allow_online,
      wchar_t *t_directory, int *e_directory_length,
       wchar_t *m_directory, int *m_directory_length){
     .
     .
     . //initializing new forms and checking product keys

    StorePath(form->SelectedEDirectory().TopDir(), e_directory,
     e_directory_length);
    StorePath(form->SelectedMDirectory(), m_directory,
     m_directory_length);
    }
Run Code Online (Sandbox Code Playgroud)

头文件:

    #if defined(_WIN32) && !BUILD_WITHOUT_DLLS &&!defined(ECLIPSE_CBUILDER_WORKAROUNDS)
    # if BUILDING_EXPORT_LIBRARY
    #  define EXPORT_DLL __declspec(dllexport)
    # else
    #  define EXPORT_DLL __declspec(dllimport)
    # endif
    #else
    #  define EXPORT_DLL
    #endif

    extern "C" …
Run Code Online (Sandbox Code Playgroud)

c# c++ pinvoke dllimport visual-studio-2013

5
推荐指数
1
解决办法
1140
查看次数

标签 统计

c# ×1

c++ ×1

dllimport ×1

pinvoke ×1

visual-studio-2013 ×1