How to pass char array to vb.net

15/09/2004 - 20:33 por Prabath Rathugama | Informe spam
Hi,



I have an eVC static dll and I need to return char array (from a
function) to a VB.NET client application. But still I couldn't able get
correct string buffer, which returned from the dll. I have data conversion
problem I guess.



Someone please help me to solve this problem.





Best Regards,

Prabath

Preguntas similare

Leer las respuestas

#1 pablo crosio
18/09/2004 - 05:43 | Informe spam
hola!

te paso un ejemplo

llamador.vb

Imports System
Imports System.Runtime.InteropServices
Imports System.Text

Class llamador
<DllImport("funciones.dll")> _
Public Shared Function F1(ByVal buffer As
StringBuilder, ByVal sizeb As Integer) As Integer
End Function

Public Shared Sub Main(ByVal args() As String)
Dim buffer As StringBuilder = New StringBuilder(100)
Console.WriteLine("F1(): {0}", F1(buffer,
buffer.Capacity))
Console.WriteLine("buffer: {0}", buffer)
End Sub
End Class



funciones.c (DLL en C)

#include <windows.h>

__declspec( dllexport ) HRESULT F1(LPSTR buffer, DWORD
sizeb)
{
memset(buffer, '\0', sizeb);
memcpy(buffer, "hola!", 5);
return 1;
}

compilar como DLL!

espero te sirva

salu2!!

pablo





Hi,



I have an eVC static dll and I need to return char


array (from a
function) to a VB.NET client application. But still I


couldn't able get
correct string buffer, which returned from the dll. I


have data conversion
problem I guess.



Someone please help me to solve this problem.





Best Regards,

Prabath






.

email Siga el debate Respuesta Responder a este mensaje
Ads by Google
Help Hacer una preguntaRespuesta Tengo una respuesta
Search Busqueda sugerida