VB.NET和C ++ Dll

时间:2014-01-20 10:34:44

标签: c++ vb.net dll

我这里的代码有问题

C ++ DLL

#include <iostream>
#include <windows.h>
#include <boost/filesystem.hpp>
#include <boost/thread/thread.hpp>
using namespace std;
using namespace boost::filesystem;
extern "C"
{
__declspec(dllexport) void IMSS_GetDirs(LPCSTR *value)
{

    directory_iterator iterator(string("D:\\"));
    for(; iterator != directory_iterator(); ++iterator)
    {
        *value = iterator->path().filename().string().c_str(); // Thats don't work , the c_str() convert to LPCSTR
        MessageBoxA(NULL,iterator->path().filename().string().c_str(),"TEST",MB_OK); // Thats also work
    }
    *value = "Test"; // Thats Work 
}
}

和VB.NET部分

    Private Declare Sub IMSS_GetDirs Lib "IMSS_SDFCCore.dll" _
   (ByRef value As String)

    Private Sub Button1_Click() Handles Button1.Click
        IMSS_GetDirs(Label1.Text)
    End Sub

那么为什么当它直接获取它的工作值以及它何时通过directory_iterator获取它不起作用?

0 个答案:

没有答案