-
IDL Import
Hi,
I have an IDL file with this structure inside:
typedef union abc
{
int Rogerio;
LPWSTR valString;
} _ABC;
When I generate the type library and make a reference in a vb.net project I cannot see the union members. But if I don't use the LPWSTR valString item, it appears with no problem.
So my question is: why using LPWSTR in unions make the whole union members not accessible?
Thanks!
-
You might need to ask C++ guys why !
-
Solution
Hi,
I've found a way:
It is possible to declare the variable as a wchar_t * .
The vb.net see the variable as a System.IntPtr pointer.
So, now it is necessary only to read the string from the memory pointer. This can be done by : Marshal.PtrToStringAuto(memoryAddress).
The final code will be like this:
typedef union abc
{
int a;
wchar_t * b;
} _abc;
the vb code:
dim x as _abc
' Reading the data from memory
Dim MyString As String = Marshal.PtrToStringAuto(x.b)
That is it!