2013-11-02 1 views
0

나는 VB 끝 반환 문자열은 VB에서

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click 
    Dim string1 As String 
    string1 = func(TextBox1.Text) 
    TextBox2.Text = string1 
End Sub 

위의 코드가 제대로 컴파일에서 다음 DLL CPP 파일

#include "stdafx.h" 
#include <string.h> 
#include <Windows.h> 
#include <OleAuto.h> 
using namespace std; 
extern "C" __declspec(dllexport) BSTR func(BSTR a) 
{ 
BSTR buffer; 
buffer = SysAllocString(a); 
return buffer; 
} 

을 가지고 있지만 양식에 문자열을 표시하기 전에 종료 텍스트 상자 내가 정수로 텍스트를 반환하는 경우, 그것은

+0

... 그것을 사용? Visual Studio 디버거를 사용하면이 문제를 디버깅 할 수 있습니다. DLL 모듈이 VB 프로젝트에서 참조되었는지 확인하고 디버깅하십시오. – WhozCraig

답변

1

BSTR ... 잘 작동! = VB.NET 문자열 내가 생각 ,,, 디버그 LPCSTR 그래서

extern "C" __declspec(dllexport) LPCSTR func(LPCSTR a)