Pass unicode string from VB.net to C++ dll
سؤال
I have tried a lot of things but I cannot get this to work. I can pass and receive ordinary strings (char*) to C++, but I cannot receive Unicode strings (w_char_t *
) in C++.
Here are some bits of the code on c++
__declspec(dllimport) int __stdcall readFile(const w_char_t *file_path)
on VB.net
Public Declare Function readFile Lib "MyDll.dll" Alias "_readFile@4" (ByVal file_path As String) As Integer
when I change w_char_t
to char
I receive the correct string.
I have found a lot of material on VB6, but not for VB.net
Any help greatly appreciated.
Leon
المحلول
Public Declare Unicode Function readFile Lib "MyDll.dll" Alias "_readFile@4" (ByVal file_path As String) As Integer
Also, your C++ code has dllexport not dllimport, right?
نصائح أخرى
Try converting UnicodeString to String (by using some System Defined Function), and then pass that string or char* to C++ DLL.
Hope this will work.
لا تنتمي إلى StackOverflow